Hello
I've looked at the reference manual for "enum" and the forums and it seems that the persistence of JDK5.0 enums is still not answered to a level I can understand...
Hibernate seems to map basic enums to a tinyblob... which is not great if one has some need to access the values via SQL outside hibernate...
Is there an
easy way to map an enum to say a string, int or sql-enum in the database?
Code:
public enum ContractType {
BORROW,
LEND
}
and the Contract:
Code:
public class Contract {
...
private ContractType type;
public void setType(ContractType type) {
this.type = type;
}
public ContractType getType() {
return type;
}
}
Mapping documents:and Contract.hbm.xml
Code:
<class name="Contract" lazy="true">
<id name="id">
<generator class="native"/>
</id>
<property name="type"/>
....
and the table created:
Code:
create table Contract (
id integer not null auto_increment,
type tinyblob
primary key (id)
)
How could I simply change the tinyblob to a string/int something non-java in the database? I can change the enum code if required...
May be could it be mapped to an sql-enum type?
Any pointer or examples would be most welcomed!
Many thanks in advance!
Benoit.
Hibernate version: 3.0.5
Name and version of the database you are using: MySQL4.1