-->
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.  [ 3 posts ] 
Author Message
 Post subject: Wrong information in Chapter 1. Tutorial
PostPosted: Wed Jan 20, 2010 12:04 am 
Newbie

Joined: Fri Nov 14, 2008 2:12 pm
Posts: 7
Location: new york
I'm following the Chapter 1 Tutorial found at:
http://docs.jboss.org/hibernate/core/3. ... orial.html
About 2/3 of the way down it states:
"If you need the identifiers of a person and an event - the save() method returns it ".
However, the save() method does not return a Long type. I'm not even sure what type it returns.
Does anybody know?


Top
 Profile  
 
 Post subject: Re: Wrong information in Chapter 1. Tutorial
PostPosted: Wed Jan 20, 2010 5:46 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Code:
<id name="id" column="PERSON_ID">
        <generator class="native"/>
    </id>


If you use generator class native, as the example does,
then the returned id type depends on the underlying database.
The example of the tutorial is based on hsqldb as database.
Which database are you using indeed ?

To know which type you get concretly, you can do following:
Object obj = session.save(person);
System.out.println(obj.getClass().getName());


Top
 Profile  
 
 Post subject: Re: Wrong information in Chapter 1. Tutorial
PostPosted: Wed Jan 20, 2010 12:23 pm 
Newbie

Joined: Fri Nov 14, 2008 2:12 pm
Posts: 7
Location: new york
Hi,
I'm using HSQLDB - as the tutorial instructs. Since I am using Maven on the command line, I didn't use System.out.println statements, and assumed everything should just work. I do have the following code in my Person.hbm.xml:
Code:
<id name="id" column="PERSON_ID">
        <generator class="native"/>
    </id>


I'll try to debug the save() method to see what's going on.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.