-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems using timestamp triggers
PostPosted: Sat Jan 05, 2008 12:41 pm 
Beginner
Beginner

Joined: Sat Jan 05, 2008 7:33 am
Posts: 26
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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 06, 2008 5:30 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Obourdon,

try with source="db", generated="always"

_________________
Gonzalo Díaz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.