I am trying to use an empty id tag in a data mapping because I have a composite key and I want to assign both keys manually. I have tried using the composite-id tag but that fails as well, so I will post that issue in a separate thread.
According to the info here:
http://www.hibernate.org/hib_docs/reference/en/html/mapping.html
Quote:
5.1.4. id
Mapped classes must declare the primary key column of the database table.
and
Quote:
If the name attribute is missing, it is assumed that the class has no identifier property.
So I should be able to have an id tag with no name attribute.
Here is the .hbm.xml file.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<id />
<property name="unitprice" column="UnitPrice" type="big_decimal" />
<property name="qty" column="Quantity" type="short" />
<property name="discount" column="Discount" />
</class>
</hibernate-mapping>
I am using hibernate through the grails framework. The exception thrown is org.hibernate.InvalidMappingException: Could not parse mapping document.
If I fill in the column info for the id tag, it works fine.