Hey, I've got a problem I can't find help on in the manual or the internet at large. I have some idea of how to do it, but I'm really not sure about it.
What I need to do: I have a few columns in the database I'm using that correspond to file formats. They come in pairs for each format, one was a path for that format and another for the size of that format. (In relation to the current row.) If they're null, that means the row I'm looking at doesn't come in that format and that I shouldn't create a new file format object and add it to a collection of formats for that row's object.
Now I'm quite happy to write a custom user type for the class I'm going to have to instantiate to encapsulate the file format information, and I think mapping them as a collection is well documented so I think that should be okay too.
It's just I'm not sure how to put in the mapping file: "if these columns are null, don't make an object, if they aren't make an object and add it to this collection." I thought it could maybe be done with formulas... or the column check="SQL expression" attribute. But I'm not sure how to get them to cancel the creation of a new object if they return false rather than just cause exceptions.
Any help would be greatly appreciated!
Thanks
Meghan
info if you need it:
Hibernate version: 3.1.3
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="edina.util.product.impl.TileImpl" table="COVERAGES" mutable="false">
<cache usage="read-only"/>
<composite-id>
<key-property name="name" type="string" column="TILE"/>
<key-property name="product"/>
</composite-id>
<property name="name" type="string" column="TILE" insert="false" update="false" />
<property name="product" type="string" column="PRODUCT"/>
<property name="amended" type="date" column="AMENDED_DATE"/>
<property name="bbox" type="edina.util.geometry.BoundingBoxUserType">
<column name="MINX" sql-type="integer" not-null="true"/>
<column name="MAXX" sql-type="integer" not-null="true"/>
<column name="MINY" sql-type="integer" not-null="true"/>
<column name="MAXY" sql-type="integer" not-null="true"/>
</property>
</class>
</hibernate-mapping>
Name and version of the database you are using: INGRES
|