Foren

Proposal: introducing datatype BigDecimal in Service-Builder

thumbnail
Jonas X. Yuan, geändert vor 13 Jahren.

Proposal: introducing datatype BigDecimal in Service-Builder

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
This thread was posted at Supporting datatype BigDecimal in ServiceBuilder. But I think it would be better to re-post it here as a proposal. Hopefully it would get more feedback.

Any application or portlet dealing with currencies should really use the java BigDecimal class. Thus It would be nice for the Service-Builder to support data-type BigDecimal.

Is it Interesting? Hope that you would be able to post your thoughts / ideas, etc.

First of all, let me introduce a proposal as follows.

1) provide data type called big_decimal in service-builder DTD

e.g.,
<column name="field6" type="BigDecimal" convert-null="false" />
<column name="field7" type="BigDecimal" convert-null="true" /> 

It would be better to add two elements for type BigDecimal in service-builder.

constraint-precision: the precision
constraint-scale: the scale

For example,

salary DECIMAL(5,2)


constraint-precision: 5
constraint-scale: 2

It can be presented as
<column name="salary" type="BigDecimal" constraint-precision="”5”" constraint-scale="”2”" convert-null="false" />


2) add new data type in Liferay core called BigDecimalType, where specifies default value;

3) map BigDecimal into NUMERIC or DECIMAL as part of SQL scripts

4) map BigDecimal into data type BigDecimalType

In above four steps, we could make data-type BigDecimal supported via Service-Builder.

You may refer to new features Service-Builder improvement for the element convert-null.

Your suggestions?

Thanks

Jonas Yuan

==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
thumbnail
Jonas Yuan, geändert vor 13 Jahren.

RE: Proposal: introducing datatype BigDecimal in Service-Builder

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
java.math.BigDecimal

Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. If zero or positive, the scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the scale. The value of the number represented by the BigDecimal is therefore (unscaledValue × 10-scale).

The BigDecimal class provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion.

In generated models and services, use java.math.BigDecimal to present data type "BigDecimal".
Vichantri Geiantilal, geändert vor 11 Jahren.

RE: Proposal: introducing datatype BigDecimal in Service-Builder

Junior Member Beiträge: 29 Beitrittsdatum: 11.06.12 Neueste Beiträge
Hello

I am trying to create the datype BigDecima in my service.xml on Liferay IDE on eclipse. I am trying to understand the folowing link http://www.liferay.com/es/web/jonas.yuan/blog/-/blogs/bringing-data-type-bigdecimal-into-service-builder but i dnt w whicjh file i hv to change or wich file i v to create i just have created my service.xml entity
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com.dados.slayer">
<author>vi</author>
<namespace>SBInfo</namespace>
<entity name="SInfo" local-service="true" table="INFO" remote-service="false"
data-source="myDatasource">
<column name="ID_INFO" type="long" primary="true"></column>
<column name="TA" type="BigDecimal" constraint-precision="30" constraint-scale="2"></column>
<column name="DF" type="BigDecimal" constraint-precision="30" constraint-scale="2" convert-null="true"></column>
</entity>
</service-builder>


What i hv to do next? this properties constraint-precision="30" constraint-scale="2" are given me error, i did not ye build the service so it can generate other files.

PLease can anyone help me?
thumbnail
Mika Koivisto, geändert vor 11 Jahren.

RE: Proposal: introducing datatype BigDecimal in Service-Builder

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
You are trying to use something that doesn't exist.
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: Proposal: introducing datatype BigDecimal in Service-Builder

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Yuan just brought it up as a proposal. Unfortunately, I don't think there is any schedule to implement it yet.
thumbnail
Jonas Yuan, geändert vor 11 Jahren.

RE: Proposal: introducing datatype BigDecimal in Service-Builder

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Vichantri,

This is a new feature. It is still in design phase. refer to Service-Builder improvement.

Thanks to @Mika and @Hitoshi

It would be nice that you could raise your comments / suggestions / feedback.
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: Proposal: introducing datatype BigDecimal in Service-Builder

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Jonas, I agree with your proposal. I don't think it'll require too much time to implement it. I think the priority level is lowered because liferay.com doesn't need it for their projects.
It may just be easier to fork out.