Hi all
I am experiencing some problems using timestamp triggers both with H2 & MySQL mappings
1) If I move the last-modified property block after any other hbm2ddl fails badly with
Executing Hibernate Tool with a Standard Configuration
1. task: hbm2ddl (Generates database schema)
14:40:56,850 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(65) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*
,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primi
tive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
To get the full stack trace run ant with -verbose
org.hibernate.InvalidMappingException: Could not parse mapping document from resource User.hbm.xml
org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-
id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-sub
class*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
/home/olivier/SOLOGICK/WKS/uShareFactory/build.xml:165: org.hibernate.InvalidMappingException: Could not parse mapping document from resource User.hbm.xml
2) if I add generated="always" my code fails badly zith
Hibernate: insert into Customers (name, full_name, gender, lang, country, region, town, email, home_phone, office_phone, mobile_phone, date_of_birth, password, uri, base_uri_appliance_favourites, base_uri_rankings, base_uri_tags, base_publish_groups, digest) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG [Thread-3] (AbstractBatcher.java:374) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG [Thread-3] (JDBCExceptionReporter.java:69) - could not insert: [org.test.User] [insert into Customers (name, full_name, gender, lang, country, region, town, email, home_phone, office_phone, mobile_phone, date_of_birth, password, uri, base_uri_appliance_favourites, base_uri_rankings, base_uri_tags, base_publish_groups, digest) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
java.sql.SQLException: Field 'last_modified' doesn't have a default value
3) I managed to get around the 1st 2 pbs but I can never get the created trigger to
work as it keeps being null valued. Am I missing something
Thanks for any help
Hibernate version:3.2.5 GA
Mapping documents:
<hibernate-mapping default-lazy="false" default-cascade="all" package="org.test">
<class name="User" table="Customers">
<id name="dbId" column="db_id" type="long">
<generator class="native"/>
</id>
<!-- Adding generated="always" makes the following fail badly
moving this code after a property def makes the ddl export fail
-->
<!-- property name="created" column="created" type="calendar"/ -->
<timestamp name="lastModified" column="last_modified"/>
<property name="created" column="created" type="calendar" insert="false" update="false" generated="insert"/>
...
Name and version of the database you are using:H2 2007-12-27 & MySQL 5.0.27
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html