-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: problem with annotations and clob
PostPosted: Thu Oct 13, 2005 11:35 am 
Newbie

Joined: Thu Oct 13, 2005 11:17 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 5:49 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Remove @Basic

I do prefer property based access cause it respect the OO encapsulation mechanism.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.