-->
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.  [ 1 post ] 
Author Message
 Post subject: Newbie, identifier of an instance altered fault
PostPosted: Tue Jan 18, 2005 11:19 am 
Newbie

Joined: Fri Jan 14, 2005 10:46 am
Posts: 1
Hi,

as new hibernate user im storing an xml document as bytearray (since www.xml-persistence.net didnt work and doenst response) in a hull Objekt
PolicyPersister.

The Objects are stored in a separate class in a spearate run (thats a problem ?).

I get the response identifier of an instance altered from one id to another - i seem to be overwriting instances.

Even though, I get every objects from my database.

Im confused :)

Any ideas appreciated-there must be a simpler way to resolve this eays task.

Thanks,
Thilo


Hibernate version:
217c
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.sun.xacml.PolicyPersister" table="POLICYPERSISTER">
<id name="Id" type="string" unsaved-value="null" >
<column name="Id" sql-type="char(100)" not-null="true"/>
<generator class="assigned"/>
</id>

<property name="ByteArray" length="200000" type="binary"/>

</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();



//List policylist = session.find( "from policypersister in class com.sun.xacml.PolicyPersister" );

//Iterator it=policylist.listIterator();
Iterator it = session.iterate("from policypersister in class com.sun.xacml.PolicyPersister");
while (it.hasNext()) {

PolicyPersister policypersister=(PolicyPersister)it.next();
System.out.println("Policy to be added");
System.out.println(policypersister.getId());


AbstractPolicy policy=parsePolicy(
policypersister.toByteArrayInputStream()
);

if (policy != null)

policies.add(policy);


} // end of while

tx.commit();
session.flush();
session.close();


} catch (HibernateException e) {
e.printStackTrace();
}

}
Full stack trace of any exception that occurs:
Hibernate: select policypersister.Id as x0_0_ from POLICYPERSISTER policypersister

Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?

Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?

Policy to be added

GeneratedPolicy

Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?

Policy to be added

ObligationPolicy

Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?

Policy to be added

SelectorPolicy

Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?

Policy to be added

TimeRangePolicy

Policy to be added

TimeRangePolicy

net.sf.hibernate.HibernateException: identifier of an instance of com.sun.xacml.PolicyPersister altered from BmwAudioFlash to TimeRangePolicy

at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2662)

at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2485)

at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2478)

at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2280)

at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)

at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)

at com.sun.xacml.finder.impl.FilePolicyModule.loadPolicies(FilePolicyModule.java:581)

at com.sun.xacml.finder.impl.FilePolicyModule.init(FilePolicyModule.java:231)

at com.sun.xacml.finder.PolicyFinder.init(PolicyFinder.java:141)

at com.sun.xacml.PDP.<init>(PDP.java:102)

at SimplePDP.<init>(SimplePDP.java:148)

at SimplePDP.main(SimplePDP.java:204)


Name and version of the database you are using:
MySQL
The generated SQL (show_sql=true):
Initializing Hibernate
15:53:07,495 INFO Environment:478 - Hibernate 2.1.7
15:53:07,505 INFO Environment:507 - hibernate.properties not found
15:53:07,505 INFO Environment:538 - using CGLIB reflection optimizer
15:53:07,515 INFO Environment:567 - using JDK 1.4 java.sql.Timestamp handling
15:53:07,515 INFO Configuration:900 - configuring from resource: /hibernate.cfg.xml
15:53:07,515 INFO Configuration:872 - Configuration resource: /hibernate.cfg.xml
15:53:07,896 INFO Configuration:331 - Mapping resource: com/sun/xacml/PolicyPersister.hbm.xml
15:53:08,056 INFO Binder:230 - Mapping class: com.sun.xacml.PolicyPersister -> POLICYPERSISTER
15:53:08,216 INFO Configuration:1058 - Configured SessionFactory: null
15:53:08,216 INFO Configuration:632 - processing one-to-many association mappings
15:53:08,216 INFO Configuration:641 - processing one-to-one association property references
15:53:08,216 INFO Configuration:666 - processing foreign key constraints
15:53:08,277 INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
15:53:08,297 INFO SettingsFactory:70 - Maximim outer join fetch depth: 2
15:53:08,297 INFO SettingsFactory:74 - Use outer join fetching: true
15:53:08,317 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
15:53:08,317 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
15:53:08,317 INFO DriverManagerConnectionProvider:77 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql:///hibernate
15:53:08,317 INFO DriverManagerConnectionProvider:78 - connection properties: {user=root, password=admin}
15:53:08,327 INFO TransactionFactoryFactory:31 - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
15:53:08,337 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
15:53:08,517 INFO SettingsFactory:114 - Use scrollable result sets: true
15:53:08,517 INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): true
15:53:08,517 INFO SettingsFactory:120 - Optimize cache for minimal puts: false
15:53:08,517 INFO SettingsFactory:126 - echoing all SQL to stdout
15:53:08,517 INFO SettingsFactory:129 - Query language substitutions: {}
15:53:08,517 INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
15:53:08,527 INFO Configuration:1121 - instantiating and configuring caches
15:53:08,647 INFO SessionFactoryImpl:119 - building session factory
15:53:09,378 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
15:53:09,388 INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
15:53:09,388 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
15:53:09,388 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
15:53:09,388 INFO DriverManagerConnectionProvider:77 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql:///hibernate
15:53:09,388 INFO DriverManagerConnectionProvider:78 - connection properties: {user=root, password=admin}
15:53:09,388 INFO SchemaUpdate:102 - Running hbm2ddl schema update
15:53:09,388 INFO SchemaUpdate:112 - fetching database metadata
15:53:09,418 INFO SchemaUpdate:127 - updating schema
15:53:09,418 INFO Configuration:632 - processing one-to-many association mappings
15:53:09,418 INFO Configuration:641 - processing one-to-one association property references
15:53:09,418 INFO Configuration:666 - processing foreign key constraints
15:53:09,438 INFO TableMetadata:39 - table found: hibernate.policypersister
15:53:09,438 INFO TableMetadata:40 - columns: [bytearray, id]
15:53:09,438 INFO TableMetadata:41 - foreign keys: []
15:53:09,438 INFO TableMetadata:42 - indexes: [primary]
15:53:09,438 INFO SchemaUpdate:146 - schema update complete
15:53:09,438 INFO DriverManagerConnectionProvider:143 - cleaning up connection pool: jdbc:mysql:///hibernate
Finished Initializing Hibernate
Hibernate: select policypersister.Id as x0_0_ from POLICYPERSISTER policypersister
Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?
Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?
Policy to be added
GeneratedPolicy
Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?
Policy to be added
ObligationPolicy
15:53:09,879 INFO DriverManagerConnectionProvider:143 - cleaning up connection pool: jdbc:mysql:///hibernate
Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?
Policy to be added
SelectorPolicy
Hibernate: select policypers0_.Id as Id0_, policypers0_.ByteArray as ByteArray0_ from POLICYPERSISTER policypers0_ where policypers0_.Id=?
Policy to be added
TimeRangePolicy
Policy to be added
TimeRangePolicy

Policy number0
net.sf.hibernate.HibernateException: identifier of an instance of com.sun.xacml.PolicyPersister altered from BmwAudioFlash to TimeRangePolicy
at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2662)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2485)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2478)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2280)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.sun.xacml.finder.impl.FilePolicyModule.loadPolicies(FilePolicyModule.java:581)
at com.sun.xacml.finder.impl.FilePolicyModule.init(FilePolicyModule.java:231)
at com.sun.xacml.finder.PolicyFinder.init(PolicyFinder.java:141)
at com.sun.xacml.PDP.<init>(PDP.java:102)
at SimplePDP.<init>(SimplePDP.java:148)
at SimplePDP.main(SimplePDP.java:204)
Debug level Hibernate log excerpt:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.