Hibernate

From Arnout Engelen

Jump to: navigation, search

(for the power management 'hibernate', see suspend/hibernate)

Contents

[edit] Database schema comparison

It'd be very nice to be able to automatically verify if a given running database schema (including constraints, foreign keys, indices etc) matches the current hibernate model.

As hbm2ddl can automatically fix those problems, it should be possible to have it merely report them. Haven't found out how though ;).

Alternatively, it might be possible to generate an sql database creation script from a running schema, also generate the schema with hbm2dll, and compare the differences. A comparison tool should be smart about ignoring differences that don't matter, like ordering and whitespace.

SchemaValidator looks interesting:

 http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/hibernate/Hibernate_Reference_Guide/Automatic_schema_generation-Schema_validation.html

[edit] rollbacks

Why didn't I find this before I wrote our interceptor?

(keywords: hibernate rollback generated id)

[edit] Bugs

[edit] SchemaUpdate

Error on oracle: erronously creates a foreign key when another foreign key with those characteristics already exists, but under another name.

[edit] Possible problems (and solutions)

[edit] javax.persistence.PersistenceException: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags

Read this and perhaps this

[edit] no persistent classes found for query class

You probably forgot to add the mapping to the hibernate.cfg.xml file.

[edit] Problems in creating a AnnotationConfiguration. Have you remembered to add it to the classpath ?

Weird problem when calling ant from eclipse (call it with `-verbose' though, there may be another error below). Goes away when calling ant from the command line. AnnotationConfiguration is in hibernate-annotations.jar

Personal tools