-->
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: pas d'insert au commit ou close
PostPosted: Tue Nov 29, 2005 11:59 am 
Newbie

Joined: Tue Nov 29, 2005 11:23 am
Posts: 3
voila,
je tourne sur Hibernate3 en tant que service .har sur jboss 4.0
j'attaque hibernate via un EJB session avec un pattern de commande

lorsque j'effectue une transaction,
le seul moyen d'effectuer l'insertion est d'utiliser flush

par exemple :

begin
persist
commit
close de ma session

j'ai comme debug :

16:45:18,312 DEBUG [CreateLanguage] Start execute
16:45:18,312 DEBUG [SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
16:45:18,312 DEBUG [SessionFactoryObjectFactory] lookup: uid=4028811407dc6a830107dcb190d00009
16:45:18,312 DEBUG [JDBCContext] successfully registered Synchronization
16:45:18,312 DEBUG [SessionImpl] opened session at timestamp: 4641911268605952
16:45:18,312 DEBUG [HibernateHelper] Session is open
16:45:18,312 DEBUG [JTATransaction] Looking for UserTransaction under: UserTransaction
16:45:18,312 DEBUG [JTATransaction] Obtained UserTransaction
16:45:18,328 DEBUG [JTATransaction] begin
16:45:18,328 DEBUG [JDBCContext] after transaction begin
16:45:18,328 DEBUG [HibernateHelper] transaction started
16:45:18,328 DEBUG [AbstractSaveEventListener] transient instance of: com.monpkg.hibernate.Language
16:45:18,328 DEBUG [DefaultSaveOrUpdateEventListener] saving transient instance
16:45:18,328 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
16:45:18,328 DEBUG [ConnectionManager] opening JDBC connection
16:45:18,328 DEBUG [SQL] select nextval ('language_idlanguage_seq')
16:45:18,328 INFO [STDOUT] Hibernate: select nextval ('language_idlanguage_seq')
16:45:18,328 DEBUG [AbstractBatcher] preparing statement
16:45:18,328 DEBUG [SequenceGenerator] Sequence identifier generated: 49
16:45:18,328 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
16:45:18,328 DEBUG [AbstractBatcher] closing statement
16:45:18,328 DEBUG [ConnectionManager] aggressively releasing JDBC connection
16:45:18,328 DEBUG [ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
16:45:18,328 DEBUG [AbstractSaveEventListener] generated identifier: 49, using strategy: org.hibernate.id.SequenceGenerator
16:45:18,328 DEBUG [AbstractSaveEventListener] saving [com.monpgk.hibernate.Language#49]
16:45:18,328 DEBUG [AbstractSaveEventListener] calling onSave()
16:45:18,328 DEBUG [APersistent] onSave Event happend
16:45:18,328 DEBUG [HibernateHelper] save done
16:45:18,328 DEBUG [JTATransaction] commit
16:45:18,328 DEBUG [HibernateHelper] Transaction commited
16:45:18,328 DEBUG [SessionImpl] closing session
16:45:18,328 DEBUG [ConnectionManager] connection already null in cleanup : no action
16:45:18,328 DEBUG [HibernateHelper] Session is closed
16:45:18,328 DEBUG [CreateLanguage] End execute
16:45:18,328 DEBUG [CacheSynchronization] transaction before completion callback
16:45:18,328 DEBUG [CacheSynchronization] automatically flushing session
16:45:18,328 DEBUG [SessionImpl] automatically flushing session
16:45:18,328 DEBUG [JDBCContext] before transaction completion
16:45:18,328 DEBUG [SessionImpl] before transaction completion
16:45:18,328 DEBUG [CacheSynchronization] transaction after completion callback, status: 3
16:45:18,328 DEBUG [JDBCContext] after transaction completion
16:45:18,328 DEBUG [SessionImpl] after transaction completion

===============================

cela ne m'insert rien en base.
en revanche si j'effectue :

begin
persist
commit
FLUSH
close de ma session

j'ai comme debug :

16:55:02,375 DEBUG [CreateLanguage] Start execute
16:55:02,390 DEBUG [SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
16:55:02,390 DEBUG [SessionFactoryObjectFactory] lookup: uid=4028811407dc6a830107dcbbc155000a
16:55:02,390 DEBUG [JDBCContext] successfully registered Synchronization
16:55:02,390 DEBUG [SessionImpl] opened session at timestamp: 4641913660989440
16:55:02,390 DEBUG [HibernateHelper] Session is open
16:55:02,390 DEBUG [JTATransaction] Looking for UserTransaction under: UserTransaction
16:55:02,390 DEBUG [JTATransaction] Obtained UserTransaction
16:55:02,406 DEBUG [JTATransaction] begin
16:55:02,406 DEBUG [JDBCContext] after transaction begin
16:55:02,406 DEBUG [HibernateHelper] transaction started
16:55:02,406 DEBUG [AbstractSaveEventListener] transient instance of: com.monpkg.hibernate.Language
16:55:02,406 DEBUG [DefaultSaveOrUpdateEventListener] saving transient instance
16:55:02,406 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
16:55:02,406 DEBUG [ConnectionManager] opening JDBC connection
16:55:02,406 DEBUG [SQL] select nextval ('language_idlanguage_seq')
16:55:02,406 INFO [STDOUT] Hibernate: select nextval ('language_idlanguage_seq')
16:55:02,406 DEBUG [AbstractBatcher] preparing statement
16:55:02,406 DEBUG [SequenceGenerator] Sequence identifier generated: 53
16:55:02,406 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
16:55:02,406 DEBUG [AbstractBatcher] closing statement
16:55:02,406 DEBUG [ConnectionManager] aggressively releasing JDBC connection
16:55:02,406 DEBUG [ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
16:55:02,406 DEBUG [AbstractSaveEventListener] generated identifier: 53, using strategy: org.hibernate.id.SequenceGenerator
16:55:02,406 DEBUG [AbstractSaveEventListener] saving [com.monpkg.hibernate.Language#53]
16:55:02,406 DEBUG [AbstractSaveEventListener] calling onSave()
16:55:02,406 DEBUG [APersistent] onSave Event happend
16:55:02,406 DEBUG [HibernateHelper] save done
16:55:02,406 DEBUG [JTATransaction] commit
16:55:02,406 DEBUG [HibernateHelper] Transaction commited
16:55:02,406 DEBUG [AbstractFlushingEventListener] flushing session
16:55:02,406 DEBUG [AbstractFlushingEventListener] processing flush-time cascades
16:55:02,406 DEBUG [AbstractFlushingEventListener] dirty checking collections
16:55:02,406 DEBUG [AbstractFlushingEventListener] Flushing entities and processing referenced collections
16:55:02,406 DEBUG [AbstractFlushingEventListener] Processing unreferenced collections
16:55:02,406 DEBUG [AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
16:55:02,406 DEBUG [AbstractFlushingEventListener] Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
16:55:02,406 DEBUG [AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
16:55:02,406 DEBUG [Printer] listing entities:
16:55:02,406 DEBUG [Printer] com.monpkg.hibernate.Language{code=Teste, eventTypeResSet=null, creationDate=29 novembre 2005, inviteFlyerResSet=null, inviteAcceptationTypeResSet=null, updateDate=29 novembre 2005, name=LangueTest, countryResSet=null, id=53, inviteCategoryResSet=null, communityCategoryResSet=null}
16:55:02,406 DEBUG [AbstractFlushingEventListener] executing flush
16:55:02,406 DEBUG [AbstractEntityPersister] Inserting entity: [com.monpkg.hibernate.Language#53]
16:55:02,406 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
16:55:02,406 DEBUG [ConnectionManager] opening JDBC connection
16:55:02,406 DEBUG [SQL] insert into language (code, name, creation_date, update_date, idlanguage) values (?, ?, ?, ?, ?)
16:55:02,406 INFO [STDOUT] Hibernate: insert into language (code, name, creation_date, update_date, idlanguage) values (?, ?, ?, ?, ?)
16:55:02,406 DEBUG [AbstractBatcher] preparing statement
16:55:02,406 DEBUG [AbstractEntityPersister] Dehydrating entity: [com.monpkg.hibernate.Language#53]
16:55:02,406 DEBUG [StringType] binding 'Teste' to parameter: 1
16:55:02,406 DEBUG [StringType] binding 'LangueTest' to parameter: 2
16:55:02,406 DEBUG [DateType] binding '29 novembre 2005' to parameter: 3
16:55:02,406 DEBUG [DateType] binding '29 novembre 2005' to parameter: 4
16:55:02,406 DEBUG [IntegerType] binding '53' to parameter: 5
16:55:02,406 DEBUG [AbstractBatcher] Adding to batch
16:55:02,406 DEBUG [AbstractBatcher] Executing batch size: 1
16:55:02,406 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
16:55:02,406 DEBUG [AbstractBatcher] closing statement
16:55:02,406 DEBUG [ConnectionManager] aggressively releasing JDBC connection
16:55:02,406 DEBUG [ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
16:55:02,406 DEBUG [AbstractFlushingEventListener] post flush
16:55:02,406 DEBUG [SessionImpl] closing session
16:55:02,406 DEBUG [ConnectionManager] connection already null in cleanup : no action
16:55:02,406 DEBUG [HibernateHelper] Session is closed
16:55:02,406 DEBUG [CreateLanguage] End execute
16:55:02,406 DEBUG [CacheSynchronization] transaction before completion callback
16:55:02,406 DEBUG [CacheSynchronization] automatically flushing session
16:55:02,406 DEBUG [SessionImpl] automatically flushing session
16:55:02,406 DEBUG [JDBCContext] before transaction completion
16:55:02,406 DEBUG [SessionImpl] before transaction completion
16:55:02,421 DEBUG [CacheSynchronization] transaction after completion callback, status: 3
16:55:02,421 DEBUG [JDBCContext] after transaction completion
16:55:02,421 DEBUG [SessionImpl] after transaction completion

==============================

la documentation precise que c'est sur le commit que l'insert de declanche mais dans mon cas, il ne se passe rien. je suis obligé de flusher.

quelqu'un aurait-il une idée ???

merci


Top
 Profile  
 
 Post subject: idem
PostPosted: Thu Jan 05, 2006 12:21 am 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
Je viens de poster un problème quasi similaire mais dans un mbean pas un ejb. As tu résolu le problème? Dans mon cas, le flush() trace bien les insert mais je n'ai toujours rien dans la base.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 9:29 am 
Newbie

Joined: Tue Nov 29, 2005 11:23 am
Posts: 3
oui, j'ai resolu ce probleme.
Le fait est que dans les EJB, il y a un contexte transactionnel JTA transparent.
il n'y a pas besoin de faire des commit ou des rollback.

Par contre je ne suis pas encore a appeler du hibernate dans mes services.
mais je pense que c'est necessaire dans ce cas de faire un beginTx et commiter a la fin. ce que je te conseillerai plutot de faire c'est que ton service appel ton EJB pour que tu uniformise et factorise ta maniere d'acceder a la persistance.


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.