@ManyToOne results in tinyblob
hispeedsurfer Feb 27, 2007 1:55 AMHi,
I'am working on JBoss-4.0.5.GA with EJB3 on MySQL.
Why a @ManyToOne join result in a tinyblob instead of a foreign-key?
My entities are a Baseentity and some derived classes with such @ManyToOne connections.
Here the BaseEntity
@MappedSuperclass
public abstract class BaseEntity implements Serializable{
@Column(name="__UUID__", unique=true, nullable=false, updatable=false, length=36)
protected String internalUUID;
protected Long id;
protected Integer version;
@Id @GeneratedValue
protected Long getId(){
return id;
}
protected void setId(Long id){
this.id = id;
}
@Version
protected Integer getVersion(){
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public BaseEntity(){
this.internalUUID = java.util.UUID.randomUUID().toString();
}
@Override
public boolean equals(Object o) {
return (o == this || (o instanceof BaseEntity && internalUUID.equals(((BaseEntity)o).internalUUID)));
}
public String toString() {
return getClass().getSimpleName() + " Id: " + getId();
}
@Override
public int hashCode() {
return internalUUID.hashCode();
}
}a derived class
@Entity
@Name("generation")
@Table(name="generations")
@SuppressWarnings("unused")
public class Generation extends BaseEntity {
/**
*
*/
private static final long serialVersionUID = 6004105498293729499L;
private String name;
/**
*
*/
public Generation() {
// TODO Auto-generated constructor stub
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}and the class with manytoone relation
@Entity
@Name("specialrelease")
@Table(name="specialreleases")
@SuppressWarnings("unused")
public class SpecialRelease extends BaseEntity {
/**
*
*/
private static final long serialVersionUID = -8813581197028149761L;
static final int NOTRELEASED = 1;
static final int NOTPERMITTED = 2;
static final int ONDEMAND = 3;
static final int DECLINED = 4;
static final int EXPIRED = 5;
static final int NOTVALID = 6;
//@NotNull
private Long requestNumber;
private String description;
@ManyToOne
private Generation generation;
/**
*
*/
public SpecialRelease() {
// TODO Auto-generated constructor stub
status = NOTRELEASED; //Genemhmigungsprozess noch nicht gestartet
}
public Generation getGeneration() {
return generation;
}
public void setGeneration(Generation generation) {
this.generation = generation;
}
}
Even I tried to put "@JoinColumn(name="generation_id", referencedColumnName="id")" to the relation the result is the same.
An idea what I can to to avoid the tinyblob?
Thanks
Andreas