-->
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: hbm2java doesnt generate @GeneratedValue annotations
PostPosted: Thu Jan 18, 2007 2:07 pm 
Newbie

Joined: Thu Nov 23, 2006 12:27 pm
Posts: 6
Hello,
I try to generate EJB3 POJOs from postgresql.
With this kind of table:

Code:
CREATE TABLE hotel
(
  id serial NOT NULL,
....
)


I have the following code generated

Code:
@Entity
@Table(name="hotel"
)
public class Hotel  implements java.io.Serializable {
     private int id;

    @Column(name="id", unique=true, nullable=false)
    public int getId() {
        return this.id;
    }


The id is not referenced as 'assigned'.

Thats my ant task
Code:
<hibernatetool destdir="${build.dir}">
         <jdbcconfiguration configurationfile="${src.dir}/hibernate.cfg.xml"
                                    packagename="fr.ccip.booking"
                                    />
        <!-- Generate hm files -->
        <hbm2java destdir="${build.dir}" jdk5="true" ejb3="true"/>
   </hibernatetool>


How may I change this generation like this
Code:
@Entity
@Name("booking")
@Table(name = "Booking" )
@SequenceGenerator(name = "booking_sequence", sequenceName = "booking_id_seq")
public class Booking implements Serializable {


    private Long id;


    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "booking_sequence")
    public Long getId() {
   return id;
    }


Thanks


Hibernate tools version: 3.2.0b9
Name and version of the database you are using: Postgres 8.1

_________________
JBOSS AS 4.0.5 EJB 3
Oracle AS 10.1.3 Hibernate 3.2.0

JDK 5


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 2:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is not hbm2java that decides which generation strategy to use its the reverse engineering (done by jdbcconfiguration)

use a reveng.xml to control the id strategy.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 4:44 am 
Newbie

Joined: Thu Nov 23, 2006 12:27 pm
Posts: 6
How may I do that ?

_________________
JBOSS AS 4.0.5 EJB 3
Oracle AS 10.1.3 Hibernate 3.2.0

JDK 5


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 4:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
stated in the docs....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 6:03 am 
Newbie

Joined: Thu Nov 23, 2006 12:27 pm
Posts: 6
OK
I just have seen how to do this programmatically

_________________
JBOSS AS 4.0.5 EJB 3
Oracle AS 10.1.3 Hibernate 3.2.0

JDK 5


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.