-->
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: Help: Could not synchronize database state with session
PostPosted: Mon Jul 17, 2006 6:55 am 
Beginner
Beginner

Joined: Thu Jun 15, 2006 5:31 am
Posts: 21
Perhaps the database is causing this problem but if so how can I see more error messages to troubleshoot this issue.

I am using posgresql - all config files, schema and code follows error stacktrace



06:42:31,171 INFO [STDOUT] Hibernate: insert into patients (version, ACTIVE_IND
, BIRTH_DT, CREATE_DT, CREATE_USER_ID, GENDER_REF_ID, RECORD_TYPE_REF_ID, SYSTEM
_ASSIGNED_VERSION_NBR, UPDATE_DT, UPDATE_USER_ID, patient_id) values (?, ?, ?, ?
, ?, ?, ?, ?, ?, ?, ?)
06:42:31,187 INFO [STDOUT] Hibernate: update patients set version=? where patie
nt_id=? and version=?
06:42:31,187 INFO [STDOUT] Hibernate: insert into PatientAddress (person_id, ad
dress_id) values (?, ?)
06:42:31,187 ERROR [AbstractFlushingEventListener] Could not synchronize databas
e state with session
org.hibernate.TransientObjectException: com.myproject.model.common.AddressModel
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(Fore
ignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeE
lement(AbstractCollectionPersister.java:732)
at org.hibernate.persister.collection.AbstractCollectionPersister.recrea
te(AbstractCollectionPersister.java:1080)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecre
ateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
at com.myproject.data.hibernate.HibernateUtil.endSession(HibernateUtil.j
ava:97)
at com.myproject.data.common.BaseData.get(BaseData.java:140)
at com.myproject.ejb.patient.PatientBean.getPatient(PatientBean.java:80)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationCo
ntextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3Int
erceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invok
e(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsI
nterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java
:197)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInt
erceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(Stateles
sInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(Authentic
ationInterceptor.java:78)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterce
ptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(Asynchrono
usInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessCo
ntainer.java:225)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRem
otingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(Se
rverThread.java:358)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.j
ava:412)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.jav
a:239)
06:42:31,234 ERROR [Log] org.hibernate.TransientObjectException: com.myproject.m
odel.common.AddressModel



CREATE TABLE addresses
(
address_id int8 NOT NULL,
version int4 NOT NULL,
active_ind int4,
address_type_ref_id int8,
city_ref_id int8,
country_ref_id int8,
county_ref_id int8,
create_dt timestamp,
create_user_id bytea,
deleted_ind int4,
other_designation varchar(255),
postal_code varchar(255),
record_type_ref_id int8,
state_ref_id int8,
street varchar(255),
system_version_nbr float8,
update_dt timestamp,
update_user_id bytea,
CONSTRAINT addresses_pkey PRIMARY KEY (address_id)
)
WITHOUT OIDS;


CREATE TABLE patientaddress
(
person_id int8 NOT NULL,
address_id int8 NOT NULL,
CONSTRAINT patientaddress_pkey PRIMARY KEY (person_id, address_id),
CONSTRAINT fkca7a954f4fe119ad FOREIGN KEY (address_id)
REFERENCES addresses (address_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fkca7a954f7c9d8623 FOREIGN KEY (person_id)
REFERENCES patients (patient_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITHOUT OIDS;

CREATE TABLE patients
(
patient_id int8 NOT NULL,
version int4 NOT NULL,
active_ind int4,
birth_dt timestamp,
create_dt timestamp,
create_user_id bytea,
gender_ref_id int8,
record_type_ref_id int8,
system_assigned_version_nbr float8,
update_dt timestamp,
update_user_id bytea,
CONSTRAINT patients_pkey PRIMARY KEY (patient_id)
)


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

<hibernate-mapping>

<class name="com.myproject.model.common.AddressModel"
table="addresses" dynamic-update="true">
<id name="id" column="address_id" type="long">
<generator class="sequence">
<param name="sequence">addresses_sequence</param>
</generator>
</id>
<version name="version"></version>

<property name="activeInd" column="ACTIVE_IND"></property>

<component name="addressType" class="com.myproject.model.common.DisplayModel">
<property name="id" column="ADDRESS_TYPE_REF_ID"></property>
</component>

<component name="city" class="com.myproject.model.common.DisplayModel">
<property name="id" column="CITY_REF_ID"></property>
</component>

<component name="country" class="com.myproject.model.common.DisplayModel">
<property name="id" column="COUNTRY_REF_ID"></property>
</component>

<component name="county" class="com.myproject.model.common.DisplayModel">
<property name="id" column="COUNTY_REF_ID"></property>
</component>

<component name="createDt" class="com.myproject.model.common.DateTimeModel">
<property name="sqlTime" column="CREATE_DT" type="timestamp"></property>
</component>

<property name="createUser" column="CREATE_USER_ID"></property>

<property name="deletedInd" column="DELETED_IND"></property>

<property name="otherDesignation" column="OTHER_DESIGNATION"></property>

<property name="postalCode" column="POSTAL_CODE"></property>

<component name="recordType" class="com.myproject.model.common.DisplayModel">
<property name="id" column="RECORD_TYPE_REF_ID"></property>
</component>

<component name="state" class="com.myproject.model.common.DisplayModel">
<property name="id" column="STATE_REF_ID"></property>
</component>

<property name="street" column="STREET"></property>

<property name="systemVersionNbr" column="SYSTEM_VERSION_NBR"></property>

<component name="updateDt" class="com.myproject.model.common.DateTimeModel">
<property name="sqlTime" column="UPDATE_DT" type="timestamp"></property>
</component>

<property name="updateUser" column="UPDATE_USER_ID"></property>



</class>

</hibernate-mapping>


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

<hibernate-mapping>

<class name="com.myproject.model.patient.PatientModel"
table="patients" dynamic-update="true">
<id name="id" column="patient_id" type="long">
<generator class="sequence">
<param name="sequence">patients_sequence</param>
</generator>
</id>
<version name="version"></version>

<property name="activeInd" column="ACTIVE_IND"></property>

<component name="birthDt" class="com.myproject.model.common.DateTimeModel">
<property name="sqlTime" column="BIRTH_DT" type="timestamp"></property>
</component>

<component name="createDt" class="com.myproject.model.common.DateTimeModel">
<property name="sqlTime" column="CREATE_DT" type="timestamp"></property>
</component>

<property name="createUser" column="CREATE_USER_ID"></property>

<component name="gender" class="com.myproject.model.common.DisplayModel">
<property name="id" column="GENDER_REF_ID"></property>
</component>

<component name="recordType" class="com.myproject.model.common.DisplayModel">
<property name="id" column="RECORD_TYPE_REF_ID"></property>
</component>

<property name="systemAssignedVersionNbr" column="SYSTEM_ASSIGNED_VERSION_NBR"></property>

<component name="updateDt" class="com.myproject.model.common.DateTimeModel">
<property name="sqlTime" column="UPDATE_DT" type="timestamp"></property>
</component>
<property name="updateUser" column="UPDATE_USER_ID"></property>
<set name="addresses" table="PatientAddress">
<key column="person_id"/>
<many-to-many column="address_id"
class="com.myproject.model.common.AddressModel"/>
</set>

</class>

</hibernate-mapping>


<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="current_session_context_class">thread</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/postgres</property>
<property name="hibernate.connection.username">myproject</property>
<property name="hibernate.connection.password">myproject</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="jta.UserTransaction">UserTransaction</property>

<mapping resource="com/myproject/model/patient/PatientModel.hbm.xml"/><mapping
resource="com/myproject/model/common/AddressModel.hbm.xml" />

</session-factory>

</hibernate-configuration>



public static void store(PatientModel model, boolean continueSession) throws Exception {
try {
if (model.getId() == null) {
HibernateUtil.getSession().save(model);
} else {
PatientModel original = (PatientModel) load(model.getClass(),model.getId(),true);
original.copyModifiedFrom(model);
HibernateUtil.getSession().save(original);
}
if (!continueSession) {
HibernateUtil.endSession();
}
} catch (Exception e) {
Log.warn(model);
HibernateUtil.rollbackSession();
throw e;
}
}


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.