Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

needing help in using hibernate

  Asked By: David    Date: Feb 02    Category: Java    Views: 1359
  

I have a problem using hibernate.:

I have 5 classes X1-X5 like these :

X1 : some fields

X2 : some fields

X3 : some fields

X4 : some fields
(foreign key to class X1) FK_X1
FK_X2 (foreign key to class X2)
FK_X3 (foreign key to class X3)

X5 :some fields
FK_X1 (foreign key to class X1)
FK_X4 (foreign key to class X4)


and the mappings for these classes are as follows :


mapping for X4 :

<many-to-one name="X1" Class="X1">
Column name ="FK_X1">>
</many-to-one>

<many-to-one name="X2" Class = "X2">
<Column name ="FK_X2">
</many-to-one>

<many-to-one name="X3" Class = "X3">
<Column name ="FK_X3">
</many-to-one>

mapping for X5 :

< <many-to-one name="X1" Class = "X1"
<Column name ="FK_X1" >
</many-to-one>

<<many-to-one name="X4" Class = "X4"
Column name ="FK_X4">>
</many-to-one>

When I want to load instances of X5 without any relation to X4 ( by removing many-to-one relation to X4 from mapping), everything is OK with just the return value from X5.getX4() is null as is supposed to be!
But when I try to load X5 instances with relation to X4 inserted, I will hit to the following exceptions :

****************************************************************************
INFO: processing foreign key constraints
May 1, 2006 5:17:20 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.Oracle9Dialect
May 1, 2006 5:17:20 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
May 1, 2006 5:17:20 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 1, 2006 5:17:20 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 3
May 1, 2006 5:17:20 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@192.168.1.150:1521:testdb
May 1, 2006 5:17:20 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=test1, password=test1}
May 1, 2006 5:17:20 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
May 1, 2006 5:17:21 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
May 1, 2006 5:17:21 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
May 1, 2006 5:17:21 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
May 1, 2006 5:17:21 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
May 1, 2006 5:17:21 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
May 1, 2006 5:17:21 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
May 1, 2006 5:17:21 PM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:ehcache-1.1.jar!/ehcache-failsafe.xml
May 1, 2006 5:17:21 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
May 1, 2006 5:17:22 PM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
May 1, 2006 5:17:31 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17027, SQLState: null
May 1, 2006 5:17:31 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Stream has already been closed
May 1, 2006 5:17:31 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17027, SQLState: null
May 1, 2006 5:17:31 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Stream has already been closed
net.sf.hibernate.exception.GenericJDBCException: could not load: [X4#6]
at net.sf.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:90)
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:79)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:416)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2131)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2001)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1963)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:208)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2219)
at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:319)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:309)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1531)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1523)
at com.adventnet.nms.startnms.ModuleDispatcher.run(ModuleDispatcher.java:73)
at com.adventnet.management.scheduler.WorkerThread.run(WorkerThread.java:68)
Caused by: java.sql.SQLException: Stream has already been closed
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:219)
at oracle.jdbc.driver.OracleStatement.getBytesInternal(OracleStatement.java:2365)
at oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.java:2438)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:285)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1308)
at net.sf.hibernate.type.StringType.get(StringType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:67)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:690)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:631)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:590)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:505)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:218)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:285)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:941)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:961)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:413)
... 22 more

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on needing help in using hibernate Or get search suggestion and latest updates.




Tagged: