Hibernate version:
hibernate 3.1 rc1
hibernate annotiations 3.1 beta 6
Mapping documents:
none, pure annotation based
@Entity(access = AccessType.FIELD)
@Table(name = "sequences")
public class Sequence implements Serializable {
@Id(generate=GeneratorType.AUTO)
private Long id;
@Basic(fetch = FetchType.LAZY)
@Column(updatable = false, nullable = false)
@Lob(type = LobType.CLOB)
private String sequenceString;
// standard getters and setters follwing
}
Code between sessionFactory.openSession() and session.close():
Transaction t = HibernateUtil.getSession().beginTransaction();
Sequence seq = new Sequence();
StringBuffer sequenceBuffer = new StringBuffer("ADCDEGAGFDGJSGAOFHJJASGEKHDJASJGEGSDMKAGDKGJ");
// repeat the next step, until we have an awful large string to store
sequenceBuffer.append("ADCDEGAGFDGJSGAOFHJJASGEKHDJASJGEGSDMKAGDKGJ");
seq.setSequenceString(sequenceBuffer.toString());
Gene g = new Gene();
g.setSequence(seq);
HibernateUtil.getSession().save(g);
t.commit();
Full stack trace of any exception that occurs:
no exception
Name and version of the database you are using:
MySQL 5.0 with mysql-connector-java-3.1.11
The generated SQL (show_sql=true):
create table sequences (id bigint not null auto_increment, sequenceString varchar(255) not null, primary key (id)) type=MyISAM
My problem is, that i want the Sequence String to be stored in a CLOB on the database side. I thought declaring @Lob(type=LobType.CLOB) does just that ? I presume that i maybe did not fully understand the documentation provided by hibernate-annotation.
And besides, can anyone point me to some information, which access-way is "better", via FIELDs or PROPERTY ? I'll just wanna know if there are any drawbacks in using the FIELDs way.
Any help appreciated!
regards, Patrick
|