-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: How to generate primitive type?
PostPosted: Fri Jun 10, 2005 6:13 am 
Beginner
Beginner

Joined: Fri Aug 20, 2004 3:45 pm
Posts: 22
Location: Florence - ITALY
I'm using Hibernate tool 3.0.0 alpha 4.

This is my hbm.

Code:
<hibernate-mapping>

   <class name="it.dp.magazzino.hibernate.XXX"
      table="XXX">
      <meta attribute="generated-class" inherit="false">it.dp.magazzino.hibernate.AbstractXXX</meta>
      <meta attribute="scope-class">public abstract</meta>

      <id name="id" type="long" unsaved-value="null">
         <generator class="increment" />
      </id>

      <property name="login" type="string" not-null="true" length="30" />
      <property name="password" type="string" not-null="true" length="30" />
      <property name="name" type="string" length="30" />
      <property name="age1" type="integer" length="3"/>
      <property name="age2" type="integer" length="3" not-null="true"/>
      <property name="age3" type="int" length="3" not-null="true"/>

   </class>

</hibernate-mapping>


The generated code is:

Code:
public abstract class AbstractXXX  implements java.io.Serializable {

    // Fields   

     private Long id;
     private String login;
     private String password;
     private String name;
     private Integer age1;
     private Integer age2;
     private Integer age3;


    // Constructors

    /** default constructor */
    public AbstractXXX() {
    }
   
    /** constructor with id */
    public AbstractXXX(Long id) {
        this.id = id;
    }

:


Why the fiels age1, age2 and age3 is all Integer instead primitive "int" type?
I would have expected that only age1 is Integer type.

Thanks.
Gianni


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 6:25 pm 
Newbie

Joined: Wed May 25, 2005 11:32 am
Posts: 14
Have you figure out this yet? I have same question. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 06, 2005 12:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The default is to non-primitive types. The primary reason is that null is the best method and certainly the easiest way to determine if the field has been initialised or not.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 11:34 am 
Newbie

Joined: Thu Aug 11, 2005 12:02 am
Posts: 6
Can we override this default behavior? If so, could you please show us how to do it? Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 12:22 pm 
Newbie

Joined: Thu Aug 11, 2005 12:02 am
Posts: 6
The link to the solution:

http://forum.hibernate.org/viewtopic.php?t=940035&highlight=primitive+type

One more modification:
<meta attribute="property-type">int</meta>
it should be "property-type" not "propert-type"

Many thinks to MAX.

Cheers
[/url]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.