Incorrect binding of variables
dornus Oct 3, 2005 10:46 AMI am getting errors when running a EntityManager.merge() operation. Checking the log files reveals that hibernate is not reading the correct values from the database.
I copied and pasted the query from the log files into the mysql query browser and ran it, and the correct results were shown.
Fo for some reason, it ignores the correct results that were returned and overrides it with some random value (I can't figure out where it's coming from).
Here's the log file chunk.
2005-10-03 10:09:21,669 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] GETTING NEW EntityManager 2005-10-03 10:09:21,669 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] logLivedSession.get() was NULL 2005-10-03 10:09:21,669 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] LONG LIVED NOT FOUND 2005-10-03 10:09:21,669 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4621715708596224 2005-10-03 10:09:21,669 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] loading entity: [par.Blog#23] 2005-10-03 10:09:21,669 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] attempting to resolve: [par.Blog#23] 2005-10-03 10:09:21,669 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] object not resolved in any cache: [par.Blog#23] 2005-10-03 10:09:21,669 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Fetching entity: [par.Blog#23] 2005-10-03 10:09:21,669 DEBUG [org.hibernate.loader.Loader] loading entity: [par.Blog#23] 2005-10-03 10:09:21,669 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 2005-10-03 10:09:21,679 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection 2005-10-03 10:09:21,679 DEBUG [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory] Using properties: {user=root, password=--hidden--} 2005-10-03 10:09:21,729 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization 2005-10-03 10:09:21,729 DEBUG [org.hibernate.SQL] select blog0_.blogId as blogId0_5_, blog0_.message as message0_5_, blog0_.header as header0_5_, blog0_.userid as userid0_5_, blog0_.dateCreated as dateCrea4_0_5_, blog0_.numViews as numViews0_5_, user1_.userid as userid20_0_, user1_.displayName as displayN2_20_0_, user1_.emailAddress as emailAdd3_20_0_, user1_.dateOfBirth as dateOfBi4_20_0_, user1_.gender as gender20_0_, user1_.firstName as firstName20_0_, user1_.lastName as lastName20_0_, user1_.fips as fips20_0_, user1_.postalCode as postalCode20_0_, locationco2_.fips as fips8_1_, locationco2_.country as country8_1_, locationzi3_.zipcode as zipcode10_2_, locationzi3_.stateId as stateId10_2_, locationzi3_.fips as fips10_2_, locationzi3_.city as city10_2_, locationzi3_.latitude as latitude10_2_, locationzi3_.longitude as longitude10_2_, locationst4_.stateId as stateId9_3_, locationst4_.name as name9_3_, locationst4_.abbreviation as abbrevia3_9_3_, locationco5_.fips as fips8_4_, locationco5_.country as country8_4_ from blog blog0_ inner join user user1_ on blog0_.userid=user1_.userid left outer join location_country locationco2_ on user1_.fips=locationco2_.fips left outer join location_zipcode locationzi3_ on user1_.postalCode=locationzi3_.zipcode left outer join location_state locationst4_ on locationzi3_.stateId=locationst4_.stateId left outer join location_country locationco5_ on locationzi3_.fips=locationco5_.fips where blog0_.blogId=? 2005-10-03 10:09:21,739 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement 2005-10-03 10:09:21,759 DEBUG [org.hibernate.type.IntegerType] binding '23' to parameter: 1 2005-10-03 10:09:21,759 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0) 2005-10-03 10:09:21,759 DEBUG [org.hibernate.loader.Loader] processing result set 2005-10-03 10:09:21,759 DEBUG [org.hibernate.loader.Loader] result set row: 0 2005-10-03 10:09:21,759 DEBUG [org.hibernate.type.IntegerType] returning '1' as column: userid20_0_ 2005-10-03 10:09:21,759 DEBUG [org.hibernate.type.StringType] returning 'US' as column: fips8_1_ 2005-10-03 10:09:21,759 DEBUG [org.hibernate.type.StringType] returning '90210' as column: zipcode10_2_ 2005-10-03 10:09:21,759 DEBUG [org.hibernate.type.IntegerType] returning '262' as column: stateId9_3_ ... more values
The last value shown above '262' is incorrect. I ran the query shown above it in the MySql Query Browser and got the correct value of '6'. So I do not know where this is coming from, or where to look to solve this.