Hi,
I am not sure if this is the correct forum to ask the question. I am trying to run an example with EJB3 on jboss with HSQL database.
I am getting the error: "ids for this class must be manually assigned before calling save" when i try to save a class with a composite pk.
It is obvious that the container is expecting to set the my pk before saving. Here is the problem: The composite key contains two fields. I wanted to generate one of the fields myself but let the system generate the other field in the key. Here is my code
my pk:
Code:
@Embeddable(access = AccessType.FIELD)
public class CategoryPK implements Serializable {
private int id;
private String type;
//this is the key I wanted auto generate
public int getId() {
return id;
}
//this is the key I wanted the user to input
public String getType() {
return type;
public boolean equals(Object obj){\\some code}
public int hashCode() {\\some code}
}
}
My class
Code:
@Entity
@Table(name = "Catgory")
public class Category implements Serializable {
private CategoryPK categoryPK;
private String description;
// my pk
@Id(generate = GeneratorType.NONE)
public CategoryPK getCategoryPK() {
return categoryPK;
}
}
Any suggestions?