As an addition to the original post...
Hibernate version:
3.0.1
Mapping documents:
OLIShip.hbm.xml
Code:
<?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="gr.forthnet.enosis.oli.pojos.OLIShip"
table="ships"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>
<id
name="code"
column="code"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-OLIShip.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<many-to-one
name="company"
class="gr.forthnet.enosis.oli.pojos.OLICompany"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="property"
property-ref="id"
column="company"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OLIShip.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
OLICompanyCode:
<?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="gr.forthnet.enosis.oli.pojos.OLICompany"
table="companies"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>
<id
name="code"
column="code"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-OLICompany.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="id"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="id"
/>
<bag
name="ships"
table="companies_ships"
lazy="false"
inverse="false"
cascade="none"
>
<key
column="company"
>
</key>
<one-to-many
class="gr.forthnet.enosis.oli.pojos.OLIShip"
/>
</bag>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OLICompany.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
OLIPort her = new OLIPort("HER");
OLIPort pir = new OLIPort("PIR");
OLICompany company = new OLICompany("ANEK");
company.setId(new Long(1));
OLIShip ship = new OLIShip("00002", company);
session.saveOrUpdate(ship);
Full stack trace of any exception that occurs:Code:
(util.JDBCExceptionReporter 57 ) SQL Error: 0, SQLState: 22P02
(util.JDBCExceptionReporter 58 ) ERROR: invalid input syntax for integer: "ANEK"
(def.AbstractFlushingEventListener 277 ) Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not delete collection: [gr.forthnet.enosis.oli.pojos.OLICompany.ships#ANEK]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:824)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:22)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:138)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at gr.forthnet.services.databases.hibernate.HiberClient.disconnect(HiberClient.java:78)
at gr.forthnet.enosis.oli.core.Schedule.main(Schedule.java:113)
Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for integer: "ANEK"
at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:271)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:814)
... 9 more
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not delete collection: [gr.forthnet.enosis.oli.pojos.OLICompany.ships#ANEK]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:824)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:22)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:138)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at gr.forthnet.services.databases.hibernate.HiberClient.disconnect(HiberClient.java:78)
at gr.forthnet.enosis.oli.core.Schedule.main(Schedule.java:113)
Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for integer: "ANEK"
at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:271)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:814)
... 9 more
Name and version of the database you are using:PostgreSQL 7.4
The generated SQL (show_sql=true):Code:
Hibernate: select oliship_.code, oliship_.company as company0_ from ships oliship_ where oliship_.code=?
Hibernate: select olicompany_.code, olicompany_.id as id1_ from companies olicompany_ where olicompany_.code=?
Hibernate: update ships set company=null where company=?
Debug level Hibernate log excerpt:Code:
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not delete collection: [gr.forthnet.enosis.oli.pojos.OLICompany.ships#ANEK]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:824)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:22)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:138)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at gr.forthnet.services.databases.hibernate.HiberClient.disconnect(HiberClient.java:78)
at gr.forthnet.enosis.oli.core.Schedule.main(Schedule.java:113)
Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for integer: "ANEK"
at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:271)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:814)
... 9 more