File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Generating the value of a property. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Generating the value of a property." Watch "Generating the value of a property." New topic
Author

Generating the value of a property.

Janhavi Namshikar
Ranch Hand

Joined: Sep 29, 2005
Posts: 85

Hi all,

I am having this problem with generating the value for a column.

I have a java bean with an attribute called "createDate" having type as Timestamp.
I have mapped this property in the .hbm.xml file as

<property name="createDate" column="create_date" update="false" type="timestamp" generated="insert"/>
I want the value for this column to be generated at insert time,as the current date time value.

The problem is with the generated="insert". If I include this in the mapping file, this is the error i am getting

Attribute "generated" must be declared for element type "property".

The Doctype declaration is as follows:

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



Any solutions on this.
Thanks in advance for the help.


"Weekends don't count unless you spend them doing something completely pointless."
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

I had a look at the dtd. Its does contain the attribute "generated" for the "property" element. Can you post your entire hbm file and the full exception stacktrace that you are seeing?


[My Blog] [JavaRanch Journal]
 
 
subject: Generating the value of a property.
 
Threads others viewed
Hibernate : generated attribute of the property element
Hibernate Mapping (Many-To-One Association). Problem. This forum is my last hope.
How could I map this if possible?
Retereive data by ORDER BY
Issue in inserting into DB using Hibernate, Spring
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com