Hi Emmanuell,
Thanks for your reply.
I have a class that serves as base for a whole bunch of classes in my object model. This class is the one that have the field I need to make static.
Here is the class:
Code:
@EmbeddableSuperclass
public class NamedPersistentSearchKey extends PersistentSearchKey implements
NamedEntity {
/**
* This method checks if the parameter is of type <code>NamedPersistentSearchKey<code>. If it is,
* it returns true if the instances have the same Id <b>OR</b> if both instances have <br>
* the same <code>name</code>.
* This method is defined
*
* @see com.thewoodexplorer.model.DbEntityImpl#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj.getClass().equals(this.getClass())){
return this == obj || super.equals(obj) || ((NamedPersistentSearchKey) obj).getName().equals(getName());
}
return false;
}
/**
*
*/
public NamedPersistentSearchKey() {
super();
}
/**
* @param theName
*/
public NamedPersistentSearchKey(String theName) {
super(theName);
}
/**
*
* @param theId
*/
public NamedPersistentSearchKey(int theId) {
super(theId);
}
/* (non-Javadoc)
* @see com.thewoodexplorer.model.NamedEntity#getName()
*/
@Column(length=2048, unique=true)
public String getName() {
if (getValue()!=null)
return getValue().toString();
else
return "";
}
/* (non-Javadoc)
* @see com.thewoodexplorer.model.NamedEntity#setName(java.lang.String)
*/
public void setName(String theName) {
setValue(theName);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
@Transient
public String toString() {
if (getValue()==null)
return "";
else
return getValue().toString();
}
}
The sql that hibernate is generating for the creation of tables for classes that extend the class above does not have the unique modifier in it.
Here is a sample:
2005-08-30 13:54:25,437 DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] - <create table Staining (
id integer not null,
name varchar(2048),
searchSection integer,
primary key (id)
)>
And here is the code for this particular class.
Code:
@Entity(access = AccessType.PROPERTY)
@org.hibernate.annotations.Proxy(lazy=false)
@Table()
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Staining extends NamedPersistentSearchKey {
/**
*
*/
public Staining() {
super();
// TODO Auto-generated constructor stub
}
/**
* @param theId
*/
public Staining(int theId) {
super(theId);
// TODO Auto-generated constructor stub
}
}
Thanks a lot..
edovale