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 hibernate and default value Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "hibernate and default value" Watch "hibernate and default value" New topic
Author

hibernate and default value

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 366
I have a column set up of id, item_id, logo and imagetype. Now I want to add a isDefault value that is used to get the first image for an item. An item can have many images but only one default per imagetype.

itemId and imagetype together can only have one isDefault set to 1 the rest should be o for isDefault. Is there anyway of doing this with Hibernate? This is what I got so far.



SCJP1.4
Chandra Sekhar
Ranch Hand

Joined: Sep 26, 2003
Posts: 90
I'm not sure whether this will solve your problem.

To set default value to a column , I had done like this before.

<property name="price" type="string" formula="CASE WHEN (COALESCE(ITEM_CST,0) = 0) THEN ' ' ELSE CHAR(ITEM_CST) END"/>


"Luck is when opportunity meets preparation"
 
 
subject: hibernate and default value
 
Threads others viewed
Hibernate One To Many Not Null
how to update OneToMany
Identity issue for EJB3.0 Entity along with Hibernate HBM configuration
Help me for Joinin two tables.
One to many Relation
developer file tools