I am wondering if it is possible to map two attributes of an object,(in this case GeneBiomarker.id and GeneBiomarker.geneSymbol) to a single column in a database which also happens to be a primary key. When I first tried this I got an error telling me i needed to set the property geneSymbol element insert="false and update="false". After doing so I got a similar message regarding the "id" attribute. So I made that insert=false and update=false as well. At that point hibernate complains about the dtd for "id" not having an insert or update element as shown below:
May 1, 2006 2:30:55 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: gov/nih/nci/caintegrator/findings/GeneBiomarker.hbm.xml
May 1, 2006 2:30:55 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(7) Attribute "insert" must be declared for element type "id".
May 1, 2006 2:30:55 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(7) Attribute "update" must be declared for element type "id".
My database is read only, so updating is not an issue.
I could add a duplicate column in my database, but the customer isn't too exciited about that. Any thoughts would be appeciated.
Thanks,
Mike
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.2
Mapping documents:
<hibernate-mapping package="gov.nih.nci.caintegrator.findings">
<class name="GeneBiomarker" table="GENE_BIOMARKER" lazy="true" polymorphism="explicit">
<id name="id" type="java.lang.String" column="GENE_SYMBOL">
<generator class="assigned" />
</id>
<property name="geneSymbol" type="java.lang.String" column="GENE_SYMBOL" insert="false" update="false" />
<many-to-one name="bioMarkerAnnotation" class="gov.nih.nci.caintegrator.findings.GeneAnnotation" column="GENE_SYMBOL" lazy="true" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: