-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate error or mysql???
PostPosted: Mon Nov 13, 2006 9:22 pm 
Newbie

Joined: Wed Nov 01, 2006 10:12 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

I get an ObjectNotFoundException though I can see that hibernate inserts the data into the database... I am using a mysql 5.0 spring 1.2.7 and hibernate 3.1.3
I am pasting a snippet of my log hibernate just says that it can't find the object though the object has been persisted into the database already.
Any help would be highly appreciated
Regards
Subu
006-11-14 00:56:23,968 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:289) - executing flush
2006-11-14 00:56:23,968 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:463) - registering flush begin
2006-11-14 00:56:23,968 DEBUG [main] entity.AbstractEntityPersister (AbstractEntityPersister.java:2034) - Inserting entity: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:23,968 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:311) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-11-14 00:56:23,968 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:346) - insert into CurrencyCodes (created, lastUpdated, Currency_Code) values (?, ?, ?)
2006-11-14 00:56:23,968 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:424) - preparing statement
2006-11-14 00:56:23,968 DEBUG [main] entity.AbstractEntityPersister (AbstractEntityPersister.java:1821) - Dehydrating entity: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:23,968 DEBUG [main] type.NullableType (NullableType.java:80) - binding '2006-11-14 00:56:23' to parameter: 1
2006-11-14 00:56:23,968 DEBUG [main] type.NullableType (NullableType.java:80) - binding '2006-11-14 00:56:23' to parameter: 2
2006-11-14 00:56:23,968 DEBUG [main] type.NullableType (NullableType.java:80) - binding 'EUR' to parameter: 3
2006-11-14 00:56:23,968 DEBUG [main] jdbc.BatchingBatcher (BatchingBatcher.java:28) - Adding to batch
2006-11-14 00:56:23,968 DEBUG [main] jdbc.BatchingBatcher (BatchingBatcher.java:55) - Executing batch size: 1
2006-11-14 00:56:23,968 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:319) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-11-14 00:56:23,968 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:470) - closing statement
2006-11-14 00:56:23,968 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:472) - registering flush end
2006-11-14 00:56:23,968 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:320) - post flush
2006-11-14 00:56:23,968 DEBUG [main] jdbc.JDBCContext (JDBCContext.java:185) - before transaction completion
2006-11-14 00:56:23,968 DEBUG [main] impl.SessionImpl (SessionImpl.java:388) - before transaction completion
2006-11-14 00:56:23,984 DEBUG [main] transaction.JDBCTransaction (JDBCTransaction.java:193) - re-enabling autocommit
2006-11-14 00:56:23,984 DEBUG [main] transaction.JDBCTransaction (JDBCTransaction.java:116) - committed JDBC Connection
2006-11-14 00:56:23,984 DEBUG [main] jdbc.JDBCContext (JDBCContext.java:199) - after transaction completion
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:398) - aggressively releasing JDBC connection
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:435) - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-11-14 00:56:24,000 DEBUG [main] impl.SessionImpl (SessionImpl.java:417) - after transaction completion
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:58) - flushing session
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:111) - processing flush-time cascades
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:153) - dirty checking collections
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:170) - Flushing entities and processing referenced collections
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:209) - Processing unreferenced collections
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:223) - Scheduling collection removes/(re)creates/updates
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:85) - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:91) - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2006-11-14 00:56:24,000 DEBUG [main] pretty.Printer (Printer.java:83) - listing entities:
2006-11-14 00:56:24,000 DEBUG [main] pretty.Printer (Printer.java:90) - org.test.test.model.CurrencyCode{created=2006-11-14 00:56:23, lastUpdated=2006-11-14 00:56:23, currencyCode=EUR}
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:289) - executing flush
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:463) - registering flush begin
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:472) - registering flush end
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:398) - aggressively releasing JDBC connection
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:320) - post flush
2006-11-14 00:56:24,000 DEBUG [main] model.CreditorBeanMapper (CreditorBeanMapper.java:107) - The date is being converted to a dd-mm-yy
2006-11-14 00:56:24,000 DEBUG [main] transaction.JDBCTransaction (JDBCTransaction.java:103) - commit
2006-11-14 00:56:24,000 DEBUG [main] impl.SessionImpl (SessionImpl.java:332) - automatically flushing session
2006-11-14 00:56:24,000 DEBUG [main] jdbc.JDBCContext (JDBCContext.java:185) - before transaction completion
2006-11-14 00:56:24,000 DEBUG [main] impl.SessionImpl (SessionImpl.java:388) - before transaction completion
2006-11-14 00:56:24,000 DEBUG [main] transaction.JDBCTransaction (JDBCTransaction.java:193) - re-enabling autocommit
2006-11-14 00:56:24,000 DEBUG [main] transaction.JDBCTransaction (JDBCTransaction.java:116) - committed JDBC Connection
2006-11-14 00:56:24,000 DEBUG [main] jdbc.JDBCContext (JDBCContext.java:199) - after transaction completion
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:398) - aggressively releasing JDBC connection
2006-11-14 00:56:24,000 DEBUG [main] jdbc.ConnectionManager (ConnectionManager.java:435) - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-11-14 00:56:24,000 DEBUG [main] impl.SessionImpl (SessionImpl.java:417) - after transaction completion
2006-11-14 00:56:24,000 DEBUG [main] def.AbstractSaveEventListener (AbstractSaveEventListener.java:462) - transient instance of: org.test.test.model.Creditor
2006-11-14 00:56:24,000 DEBUG [main] def.DefaultMergeEventListener (DefaultMergeEventListener.java:140) - merging transient instance
2006-11-14 00:56:24,000 DEBUG [main] engine.Cascade (Cascade.java:237) - processing cascade ACTION_MERGE for: org.test.test.model.Creditor
2006-11-14 00:56:24,015 DEBUG [main] def.DefaultLoadEventListener (DefaultLoadEventListener.java:153) - loading entity: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:24,015 DEBUG [main] def.DefaultLoadEventListener (DefaultLoadEventListener.java:304) - attempting to resolve: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:24,015 DEBUG [main] def.DefaultLoadEventListener (DefaultLoadEventListener.java:340) - object not resolved in any cache: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:24,015 DEBUG [main] entity.AbstractEntityPersister (AbstractEntityPersister.java:2723) - Fetching entity: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:24,015 DEBUG [main] loader.Loader (Loader.java:1777) - loading entity: [org.test.test.model.CurrencyCode#EUR]
2006-11-14 00:56:24,015 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:311) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-11-14 00:56:24,015 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:346) - select currencyco0_.Currency_Code as Currency1_6_0_, currencyco0_.created as created6_0_, currencyco0_.lastUpdated as lastUpda3_6_0_ from CurrencyCodes currencyco0_ where currencyco0_.Currency_Code=?
2006-11-14 00:56:24,031 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:424) - preparing statement
2006-11-14 00:56:24,031 DEBUG [main] type.NullableType (NullableType.java:80) - binding 'EUR' to parameter: 1
2006-11-14 00:56:24,031 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:327) - about to open ResultSet (open ResultSets: 0, globally: 0)
2006-11-14 00:56:24,031 DEBUG [main] loader.Loader (Loader.java:682) - processing result set
2006-11-14 00:56:24,031 DEBUG [main] loader.Loader (Loader.java:709) - done processing result set (0 rows)
2006-11-14 00:56:24,031 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:334) - about to close ResultSet (open ResultSets: 1, globally: 1)
2006-11-14 00:56:24,031 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:319) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-11-14 00:56:24,031 DEBUG [main] jdbc.AbstractBatcher (AbstractBatcher.java:470) - closing statement
2006-11-14 00:56:24,031 DEBUG [main] loader.Loader (Loader.java:839) - total objects hydrated: 0
2006-11-14 00:56:24,031 DEBUG [main] engine.StatefulPersistenceContext (StatefulPersistenceContext.java:748) - initializing non-lazy collections
2006-11-14 00:56:24,031 DEBUG [main] loader.Loader (Loader.java:1808) - done entity load
2006-11-14 00:56:24,031 INFO [main] def.DefaultLoadEventListener (DefaultLoadEventListener.java:95) - Error performing load command
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.test.test.model.CurrencyCode#EUR]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:128)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:161)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.type.EntityType.replace(EntityType.java:207)
at org.hibernate.type.AbstractType.replace(AbstractType.java:153)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:447)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:302)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:159)
at org.test.persistence.hibernate.TimestampingMergeEventListener.entityIsTransient(TimestampingMergeEventListener.java:43)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:103)
at org.test.persistence.hibernate.TimestampingMergeEventListener.onMerge(TimestampingMergeEventListener.java:34)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:52)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:672)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:656)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:660)
at org.test.persistence.hibernate.TramadaTransaction.create(TramadaTransaction.java:81)
at org.test.persistence.hibernate.HibernatePersistenceServiceImpl.create(HibernatePersistenceServiceImpl.java:40)
at org.test.test.model.CreditorServiceImpl.saveCreditor(CreditorServiceImpl.java:51)
at org.test.test.model.BatchProcessing.doBulkRead(BatchProcessing.java:131)
at org.test.test.model.BatchProcessing.main(BatchProcessing.java:167)


Top
 Profile  
 
 Post subject: Can you ...
PostPosted: Tue Nov 14, 2006 12:19 am 
Newbie

Joined: Mon Jun 20, 2005 11:38 am
Posts: 7
Post the code of the class org.test.test.model.CurrencyCode, and the hbm.xml file associated.

Your class is it a userType ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 7:50 pm 
Newbie

Joined: Wed Nov 01, 2006 10:12 pm
Posts: 4
Currency code is just a bean like this.
@IgnoreListenerParameters
public class CurrencyCode extends Persistable {

private String currencyCode;
private Date lastUpdated;
private Date created;

CurrencyCode(){

}

public void finalize() throws Throwable {

}

public String getCurrencyCode ()
{
return currencyCode;
}

public void setCurrencyCode ( String currencyCode )
{
this.currencyCode = currencyCode;
}
@IgnoreFieldsForTest

public Integer getId ()
{

return null;
}

public void setId ( Integer id )
{


}
@IgnoreFieldsForTest

public Date getLastUpdated ()
{

return lastUpdated;
}

public void setLastUpdated ( Date timestamp )
{
lastUpdated=timestamp;


}
@IgnoreFieldsForTest

public Date getCreated ()
{

return created;
}

public void setCreated ( Date timestamp )
{
created=timestamp;

}





public boolean equals ( Object other )
{
if ( !(other instanceof CurrencyCode) ) return false;
final CurrencyCode that = (CurrencyCode) other;
return that.currencyCode.equals ( this.currencyCode);
}

@Override
public int hashCode ()
{
return currencyCode.hashCode ();
}


}


and relavent hbm.xml
<class name="CurrencyCode" table="CurrencyCodes" lazy="false">
<id name="currencyCode" type="string" column="Currency_Code">
<generator class="assigned" />
</id>
<property name="created">
<column name="created" />
</property>
<property name="lastUpdated">
<column name="lastUpdated" />
</property>


</class>

and in the parent class
<many-to-one name="currencyCode"
class="CurrencyCode"
column="Currency_Code" unique="true" cascade="save-update" />


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 11:51 pm 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Mysql 5 has an automatic rollback feature if it thinks the data integrity is at a loss. Search through dev.mysql.com for automatic rollback. I had a similar problem earlier (not exactly the same scenario but record inserted and not found later). Switch to HSQL and see if your testcase works fine.
To make sure that Mysql is the problem, turn on mysql logging by hvaing a log=/tmp/test.log in the /etc/my.cnf and restart mysql. After the insert that you would have , there woul dbe a commit(that Hibernate sends out) followed by a rollback(generated by mysql). That was the case with me but Hibernate never sent the rollback, it was done by Mysql. Looking at the log will confirm that the problem is with mysql.


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