Hi David,
Tried your second suggestion, and puzzled by the results!!
I have an INFO table, which just stores version number and serial number. It will only ever have 1 row.
So I simply made the version number the primary key, and regenerated everything. The problem is I get a strange error:
net.sf.hibernate.MappingException: composite-id class must override equals(): com.lexmark.kiosk.hibernate.Info
There isn't a composite-id anywhere in sight though!! (as far as I can tell). The table sits by itself, with no relationships, and just the primary key.
All the info's below.
cheers,
David
DDL:
CREATE TABLE "KIOSK"."INFO"
(
"VERSION" Varchar (10) ASCII NOT NULL,
"SERIAL_NUMBER" Varchar (7) ASCII NOT NULL,
PRIMARY KEY ("VERSION")
)
HBM:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.lexmark.kiosk.hibernate.Info"
table="INFO"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="INFO"
</meta>
<id
name="version"
type="java.lang.String"
column="VERSION"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.String"
column="VERSION"
</meta>
<generator class="assigned" />
</id>
<property
name="serialNumber"
type="java.lang.String"
column="SERIAL_NUMBER"
not-null="true"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="SERIAL_NUMBER"
length="7"
not-null="true"
</meta>
</property>
<!-- Associations -->
</class>
</hibernate-mapping>
JAVA:
package com.lexmark.kiosk.hibernate;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* @hibernate.class
* table="INFO"
*
*/
public class Info implements Serializable {
/** identifier field */
private String version;
/** persistent field */
private String serialNumber;
/** full constructor */
public Info(String version, String serialNumber) {
this.version = version;
this.serialNumber = serialNumber;
}
/** default constructor */
public Info() {
}
/**
* @hibernate.id
* generator-class="assigned"
* type="java.lang.String"
* column="VERSION"
*
*/
public String getVersion() {
return this.version;
}
public void setVersion(String version) {
this.version = version;
}
/**
* @hibernate.property
* column="SERIAL_NUMBER"
* length="7"
* not-null="true"
*
*/
public String getSerialNumber() {
return this.serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String toString() {
return new ToStringBuilder(this)
.append("version", getVersion())
.toString();
}
}