JPA2 / Hibernate - Numeric(x,y) mapping to java.lang.Integer

41 views
Skip to first unread message

ggran...@gmail.com

unread,
Dec 2, 2015, 12:09:37 PM12/2/15
to minuteproject
Hi Florian,

How do I tell the code generation to map Numeric to floating point representations?   Mine all seem to be mapping to Integer.

Thanks,
-Greg

ggran...@gmail.com

unread,
Dec 2, 2015, 12:48:32 PM12/2/15
to minuteproject
I should include some information/examples about my database.   See attached.
SQLServerVersion.png
SessionTargetEventTable.png
SessionTargetEventDomainClass.png

ggran...@gmail.com

unread,
Dec 2, 2015, 12:58:59 PM12/2/15
to minuteproject
More information - as I research this problem it looks like the code generation is correct for "decimal(x,y)" but not for "numeric(x,y)".   From the documentation, those should be equivalent.


On Wednesday, December 2, 2015 at 11:09:37 AM UTC-6, ggran...@gmail.com wrote:

Florian Adler

unread,
Dec 3, 2015, 10:03:06 AM12/3/15
to minute...@googlegroups.com
Hello,

Thanks for your feedback.
It is probably a bug. I'll fix it.

Best regards,

Florian.

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "minuteproject".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse minuteprojec...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

ggran...@gmail.com

unread,
Sep 7, 2016, 11:52:49 AM9/7/16
to minuteproject
Hi Florian,

I just got latest to check for this fix and noticed that changes have been made in this regard.  Unfortunately I am now getting compile errors in the generation of domain entities as noted below:

I have a table called LaneConfig that has 2 numerics that generate BigDecimals.  The all fields constructor is generated correctly and shows this:

public LaneConfig(
       Integer laneConfigId,
       java.math.BigDecimal XCenter,
       java.math.BigDecimal widthPercent,
       java.util.Date createdDate,
       java.util.Date modifiedDate,
       String createdBy,
       String modifiedBy,
       Integer lockVersion
    , boolean setRelationship) {
       //primary keys
       setLaneConfigId (laneConfigId);
       //attributes
       setXCenter (XCenter);
       setWidthPercent (widthPercent);
       setCreatedDate (createdDate);
       setModifiedDate (modifiedDate);
       setCreatedBy (createdBy);
       setModifiedBy (modifiedBy);
       setLockVersion (lockVersion);
       //parents
    }

But there is a static mask function that still thinks those 2 BigDecimals are Integer type:

public static LaneConfig fullMask() {
return new LaneConfig(
integerMask__ ,
integerMask__ ,                          <--------------Should be bigDecimalMask__
integerMask__ ,                          <--------------Should be bigDecimalMask__
timestampMask__ ,
timestampMask__ ,
stringMask__ ,
stringMask__ ,
integerMask__ );
}

There is also a mask method generates incorrectly again assuming the fields are Integer:

    public LaneConfig mask(String pattern, Object value) {
        if(pattern==null || value==null) return this;
if ("laneConfigId".equals(pattern)) {
           setLaneConfigId((Integer)value);
  return this;
}
if ("XCenter".equals(pattern)) {
           setXCenter((Integer)value);                           <--------------Should be BigDecimal
  return this;
}
if ("widthPercent".equals(pattern)) {
           setWidthPercent((Integer)value);                  <--------------Should be BigDecimal
  return this;
}

Also, I noticed with the latest source that my pom file is getting overwritten by a generated version.   Is there a way I can prevent that?

Regards,
-Greg

Florian Adler

unread,
Sep 8, 2016, 3:48:34 PM9/8/16
to minute...@googlegroups.com
Hi Greg,

Thanks for your feedback,
I will try to fix it quickly, for bigDecimal.

If you generate over an existing artifact (ex: a pom.xml), but you want to keep your modification, the best is to :
1) Add MP-MANAGED-STOP-GENERATING as a comment ex:
<!-- MP-MANAGED-STOP-GENERATING --> for xml inside the modified artifact.

2) Instruct the generator to detect that files may be updated:
Add target-convention node inside your configuration:
<generator-config>
    <configuration>
        <conventions>
            <target-convention type="enable-updatable-code-feature" />
        </conventions>


There are also some details at http://minuteproject.wikispaces.com/Updatable_Generated_Code

Remark:
You can also try to add //MP-MANAGED-STOP-GENERATING in the java file LaneConfig 


Best regards,

Florian.


Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse minuteproject+unsubscribe@googlegroups.com.

ggran...@gmail.com

unread,
Sep 13, 2016, 2:22:21 PM9/13/16
to minuteproject
Hi Florian,

I was wondering about the status of this fix.

Also, I want to generate from my schema a set of simple serializable transfer classes annotated with XML - Simple beans I guess they could be called.  Is there a target that will do that?

Florian Adler

unread,
Sep 21, 2016, 4:08:35 AM9/21/16
to minute...@googlegroups.com
Hello Greg,

Regarding xml, maybe there is a way:
Add 

<property name="add-xmlbinding" value="true"></property>

Inside the target node:


<targets catalog-entry="JPA2"
append-catalog-entry-dir-to-outputdir-root="true"  
outputdir-root="../../product/sampleProduct" >
<property name="add-xmlbinding" value="true"/>
</targets>

You should have Xml annotation generated:

@XmlType
@XmlRootElement
@XmlElement

But you still have JPA annotations...

Best regards,

Florian.

Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse minuteproject+unsubscribe@googlegroups.com.

ggran...@gmail.com

unread,
Sep 30, 2016, 3:20:31 PM9/30/16
to minuteproject
Great.  Thanks.

Do you have a fix for the Integer/BigDecimal issue?  I can't generate source from schema without a big edit afterward.

ggran...@gmail.com

unread,
Oct 26, 2016, 3:14:24 PM10/26/16
to minuteproject
Hi Florian,

The Integer/BigDecimal issue is causing me some pain at every code generation.   Please advise me.   Should I look into fixing this?  Is all of the source included in the download?   Perhaps you can point me in the right direction.

Regards,
-Greg

Florian Adler

unread,
Oct 27, 2016, 4:59:14 AM10/27/16
to minute...@googlegroups.com
Hello,

I was not able to reproduce it on mysql where I use numeric (9,6) for geo loc latitude/longitude. Apparently you are using ms sqlserver which I have not tested.
I have meanwhile made a patch in release 0.9.9 (https://sourceforge.net/projects/minuteproject/files/0.9/0.9.9/minuteProject-0.9.9.zip/download) for this issue.
Maybe you can test it.

Best regards,

Florian.

Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse minuteproject+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages