-->
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.  [ 2 posts ] 
Author Message
 Post subject: Record not saved to Database
PostPosted: Tue Nov 17, 2009 1:59 pm 
Newbie

Joined: Tue Nov 17, 2009 1:45 pm
Posts: 4
Hello
I am new to Hibernate as i previously used Ibatis.

I am facing a problem. I Have written a code to save a record to database when the code executes nothing goes wrong (ie no error or exception). But i dont find any records Saved in Database :(
Please note that there is many to one relationship of Event with other tables. and while saving event record i am not saving other tables instance(As i dont like/need to). Please help
here is code

Code:
Transaction tx = session.beginTransaction();

      EventDAO eventDAO = new EventDAO();
      Event event = new Event();
      event.setClaimantComments("adf");
      event.setDocumentDetails("adsf");
      event.setDocumentRef("dsaf");
      event.setEventDate(new Date());
      event.setEventName("Event name");
      event.setExcludeinclude("adf");
      event.setPrincipalComments("c");
      event.setEventId(IDGenerator.getUniqueIdForEvent());
      eventDAO.save(event);

      tx.commit();


here is part of output on console
Quote:
INFO [main] (SettingsFactory.java:90) - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 603)
INFO [main] (Dialect.java:152) - Using dialect: org.hibernate.dialect.PostgreSQLDialect
INFO [main] (TransactionFactoryFactory.java:31) - Using default transaction strategy (direct JDBC transactions)
INFO [main] (TransactionManagerLookupFactory.java:33) - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO [main] (SettingsFactory.java:143) - Automatic flush during beforeCompletion(): disabled
INFO [main] (SettingsFactory.java:147) - Automatic session close at end of transaction: disabled
INFO [main] (SettingsFactory.java:154) - JDBC batch size: 15
INFO [main] (SettingsFactory.java:157) - JDBC batch updates for versioned data: disabled
INFO [main] (SettingsFactory.java:162) - Scrollable result sets: enabled
INFO [main] (SettingsFactory.java:170) - JDBC3 getGeneratedKeys(): disabled
INFO [main] (SettingsFactory.java:178) - Connection release mode: auto
INFO [main] (SettingsFactory.java:205) - Default batch fetch size: 1
INFO [main] (SettingsFactory.java:209) - Generate SQL with comments: disabled
INFO [main] (SettingsFactory.java:213) - Order SQL updates by primary key: disabled
INFO [main] (SettingsFactory.java:217) - Order SQL inserts for batching: disabled
INFO [main] (SettingsFactory.java:386) - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO [main] (ASTQueryTranslatorFactory.java:24) - Using ASTQueryTranslatorFactory
INFO [main] (SettingsFactory.java:225) - Query language substitutions: {}
INFO [main] (SettingsFactory.java:230) - JPA-QL strict compliance: disabled
INFO [main] (SettingsFactory.java:235) - Second-level cache: enabled
INFO [main] (SettingsFactory.java:239) - Query cache: disabled
INFO [main] (SettingsFactory.java:373) - Cache provider: org.hibernate.cache.NoCacheProvider
INFO [main] (SettingsFactory.java:254) - Optimize cache for minimal puts: disabled
INFO [main] (SettingsFactory.java:263) - Structured second-level cache entries: disabled
INFO [main] (SettingsFactory.java:290) - Statistics: disabled
INFO [main] (SettingsFactory.java:294) - Deleted entity synthetic identifier rollback: disabled
INFO [main] (SettingsFactory.java:309) - Default entity-mode: pojo
INFO [main] (SettingsFactory.java:313) - Named query checking : enabled
INFO [main] (SessionFactoryImpl.java:161) - building session factory
INFO [main] (SessionFactoryObjectFactory.java:82) - Not binding factory to JNDI, no JNDI name configured


Kind Regards


Top
 Profile  
 
 Post subject: Re: Record not saved to Database
PostPosted: Tue Nov 17, 2009 4:30 pm 
Newbie

Joined: Wed Jun 14, 2006 7:40 pm
Posts: 8
The question here is what the EventDao does in its save method - how it is retrieving the session that you have on the first line.

If you want you can change the following line in your code

eventDAO.save(event);

to

session.save(event);

and then check if you have the record in the database - if you do then most likely there is something wrong in you DAO class.


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