Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / December 2004

Tip: Looking for answers? Try searching our database.

Does this Hibernate generated SQL mean anything to anyone?

Thread view: 
IINET - 23 Dec 2004 07:48 GMT
Generated sql:
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into PERSON (name, address, id) values (?, ?, ?)

Everything seems to be working - no errors at all. But my class is not being
saved to the database! I get the session, do the save, the flush etc - but
no action in the database itself.

Should I not be seeing the actual SQL and not the ? ? ? business? My class
is folowing all the right rules (private members, no arg constructor etc

CODE:

Person person1 = new Person();
person1.setName("Basil Fawlty");
person1.setAddress("Fawlty Towers, UK");

try {
Session session = HibernateUtil.currentSession();
session.save(person1);
session.flush();
HibernateUtil.closeSession();

} catch (Exception ex) {
System.out.println("Problem with servlet code: " + ex.getMessage());
}

help appreciated.
Mark Scott - 23 Dec 2004 11:35 GMT
[...]

> Person person1 = new Person();
> person1.setName("Basil Fawlty");
[quoted text clipped - 9 lines]
> System.out.println("Problem with servlet code: " + ex.getMessage());
> }

Do the work in a Transaction.  Look at the code idiom in the javadoc for
Session (or look at the example in the Hibernate doc, just under the
definition of HibernateUtil (assuming it's that implementation you're
using)).

HTH.

Signature

Mark Scott
mark@codebrewer.com

                      GPG Key ID: 0x2CCE1173 - signed/encrypted mail preferred



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.