This page lists common issues which you can encounter when using the [[CDO_Hibernate_Store|CDO Hibernate Store]].

+

This page lists common issues which you can encounter when using the [[CDO/Hibernate_Store|CDO Hibernate Store]].

+

+

As a first step often it makes sense to check the hibernate mapping generated by the hibernate store. See [[CDO/Hibernate_Store/Configuration_and_Setup#How_to_get_to_the_hibernate_mapping|here]] for how to get to this mapping.

=== My database does not get created ===

=== My database does not get created ===

−

Hibernate will not create the database for you, you have to manually create a database. You don't need to create the tables and other database schema parts. That's done by hibernate.

+

Hibernate will not create the database for you, you have to manually create a database. You don't need to create the tables and other database schema parts. That's done by Hibernate.

=== Hibernate drops my database when the application stops ===

=== Hibernate drops my database when the application stops ===

−

This is probably the hibernate.hbm2ddl.auto property in the cdo-server.xml, change it from 'create-drop' to 'update'.

+

This is probably the [http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html <tt>hibernate.hbm2ddl.auto</tt> property] in the <tt>cdo-server.xml</tt>, change it from <tt>create-drop</tt> to <tt>update</tt>.

===JPA Annotations in the model are not picked up by Teneo===

===JPA Annotations in the model are not picked up by Teneo===

Line 16:

Line 18:

===My JPA annotation XML file is not visible to Teneo, I see related exceptions in the log===

===My JPA annotation XML file is not visible to Teneo, I see related exceptions in the log===

Make sure that:

Make sure that:

−

* the relevant property (teneo.mapping.persistence_xml)is set in the cdo-server.xml, the value must be a classpath path, for example: /org/eclipse/emf/cdo/hibernate/annotations/annotations.xml (if the annotations.xml is located in the org.eclipse.emf.cdo.hibernate.annotations package.

+

* the relevant property (teneo.mapping.persistence_xml) is set in the cdo-server.xml, the value must be a classpath path, for example: /org/eclipse/emf/cdo/hibernate/annotations/annotations.xml (if the annotations.xml is located in the org.eclipse.emf.cdo.hibernate.annotations package.

* the package/path in which the annotations xml file is present must be exported by the plugin. An alternative is to place the annotations xml file in the /META-INF directory of the plugin then it is copied to the output path automatically.

* the package/path in which the annotations xml file is present must be exported by the plugin. An alternative is to place the annotations xml file in the /META-INF directory of the plugin then it is copied to the output path automatically.

* the annotations xml file is copied to the output path, it should be explicitly flagged in the build.properties in the bin.includes/binary build part.

* the annotations xml file is copied to the output path, it should be explicitly flagged in the build.properties in the bin.includes/binary build part.

* the plugin which contains the annotations xml should depend on the org.eclipse.emf.cdo.server.hibernate.teneo plugin (otherwise the Teneo plugins won't be able to reach the annotations file).

* the plugin which contains the annotations xml should depend on the org.eclipse.emf.cdo.server.hibernate.teneo plugin (otherwise the Teneo plugins won't be able to reach the annotations file).

+

+

===With Teneo I can use a manual hbm file also, is that possible with the CDO Hibernate store?===

+

Yes, that's possible. However, the file generated for Teneo standard will not work for the CDO Hibernate store. You need to generate a new one. See [[CDO/Hibernate_Store/Model_Relational_Mapping#Generating_the_mapping.2C_manually_changing_it_and_then_use_the_manual_mapping|here]] for more information.

+

+

=== How can I see the Hibernate SQL statements? ===

+

See [[CDO/Hibernate_Store/Configuration_and_Setup#How_to_enable_Hibernate_logging|here]] for details on how to setup logging in Hibernate with CDO.

+

+

=== My insert statements fail with table not found or similar statements ===

+

Depending on the setting of the hibernate.hbm2ddl.auto property Hibernate will automatically create the tables for you. However, Hibernate will often ignore failing create table statements and start up without throwing exceptions. It is often best to check the created tables in the database directly.

+

+

Enable hibernate logging (see above) and then specifically the log4j.logger.org.hibernate.tool.hbm2ddl setting to get more details of the create table statements.

The CDO Hibernate plugins make use of the import-packages directive for defining dependencies. If you run junit testcases in 'normal' (non-plugin) mode then these import-packages are only resolved against explicitly declared dependencies and not against installed plugins or the target platform. See [[/CDO_Hibernate_Store_Configuration_and_Setup#Running_your_own_junit_testcases|here]] for a more detailed description and solution.

+

+

=== Error Rollback: revision was not registered ===

+

+

When you get the stack trace below check for the following situation: you have an explicit version attribute in your type which has -1 as the default value. To solve this change the default value to 0.

Hibernate drops my database when the application stops

JPA Annotations in the model are not picked up by Teneo

To make the JPA annotations in the model visible you need to regenerate the java code. EMF creates the in-memory ecore package using the generated java code (depends on a configuration setting) and not the original ecore file.

My JPA annotation XML file is not visible to Teneo, I see related exceptions in the log

Make sure that:

the relevant property (teneo.mapping.persistence_xml) is set in the cdo-server.xml, the value must be a classpath path, for example: /org/eclipse/emf/cdo/hibernate/annotations/annotations.xml (if the annotations.xml is located in the org.eclipse.emf.cdo.hibernate.annotations package.

the package/path in which the annotations xml file is present must be exported by the plugin. An alternative is to place the annotations xml file in the /META-INF directory of the plugin then it is copied to the output path automatically.

the annotations xml file is copied to the output path, it should be explicitly flagged in the build.properties in the bin.includes/binary build part.

the plugin which contains the annotations xml should depend on the org.eclipse.emf.cdo.server.hibernate.teneo plugin (otherwise the Teneo plugins won't be able to reach the annotations file).

With Teneo I can use a manual hbm file also, is that possible with the CDO Hibernate store?

Yes, that's possible. However, the file generated for Teneo standard will not work for the CDO Hibernate store. You need to generate a new one. See here for more information.

How can I see the Hibernate SQL statements?

My insert statements fail with table not found or similar statements

Depending on the setting of the hibernate.hbm2ddl.auto property Hibernate will automatically create the tables for you. However, Hibernate will often ignore failing create table statements and start up without throwing exceptions. It is often best to check the created tables in the database directly.

Enable hibernate logging (see above) and then specifically the log4j.logger.org.hibernate.tool.hbm2ddl setting to get more details of the create table statements.

I am getting ClassNotFoundExceptions when running junit testcases

The CDO Hibernate plugins make use of the import-packages directive for defining dependencies. If you run junit testcases in 'normal' (non-plugin) mode then these import-packages are only resolved against explicitly declared dependencies and not against installed plugins or the target platform. See here for a more detailed description and solution.

Error Rollback: revision was not registered

When you get the stack trace below check for the following situation: you have an explicit version attribute in your type which has -1 as the default value. To solve this change the default value to 0.

[ERROR] Rollback in HibernateStore: java.lang.IllegalStateException:
Revision was not registered:
GeneralVars@OID:#300000048:0v0
at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext.addRevisions(TransactionCommitContext.java:728)
at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext.updateInfraStructure(TransactionCommitContext.java:669)
at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext.commit(TransactionCommitContext.java:316)
at
org.eclipse.emf.cdo.spi.server.InternalCommitContext$2.runLoop(InternalCommitContext.java:45)
at
org.eclipse.emf.cdo.spi.server.InternalCommitContext$2.runLoop(InternalCommitContext.java:1)
at
org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
at
org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:266)
at
org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:162)
at
org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:116)
at
org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
at
...