I use :
mysql-connector-java 6.0.6
hibernate 5.2.10.Final
spring 4.3.8.RELEASE
Class code :
public class PhoneNumber extends AbstractValue{
public static final int CELL_PHONE = 1, HOME_PHONE = 2, WORK_PHONE = 3;
public PhoneNumber(String value, Integer type) {
super(value, type);
}
public PhoneNumber() {
this(null,null);
}
}
Parent class :
public abstract class AbstractValue {
private String value;
private Integer type;
public AbstractValue(String value, Integer type) {
this.value = value;
this.type = type;
}
public String getValue() {
return value;
}
public Integer getType() {
return type;
}
public void setValue(String value) {
this.value = value;
}
public void setType(Integer type) {
this.type = type;
}
}
Mapping :
<entity class="PhoneNumber" name="PhoneNumber">
<table name="PhoneNumber"/>
<attributes>
<id name="value">
</id>
<basic name="type">
<column nullable="false"/>
</basic>
</attributes>
</entity>
Already tried :
<entity class="PhoneNumber" name="PhoneNumber">
<table name="PhoneNumber"/>
<attributes>
<id name="value" access="FIELD">
<generated-value strategy="SEQUENCE" generator="IdSeq" />
<sequence-generator name="IdSeq" sequence-name="IdSeq" allocation-size="1" />
</id>
<basic name="type">
<column nullable="false"/>
</basic>
</attributes>
</entity>
<entity class="PhoneNumber" name="PhoneNumber">
<table name="PhoneNumber"/>
<attributes>
<id name="value">
<generated-value strategy="IDENTITY" generator="uuid" />
</id>
<basic name="type">
<column nullable="false"/>
</basic>
</attributes>
</entity>
<entity class="PhoneNumber" name="PhoneNumber">
<table name="PhoneNumber"/>
<attributes>
<id name="value">
<generated-value strategy="TABLE" generator="uuid" />
<table-generator name="uuid" />
</id>
<basic name="type">
<column nullable="false"/>
</basic>
</attributes>
</entity>
And already read : (so i hope i don't do duplicate)
org.hibernate.AnnotationException: No identifier specified for entity: com.ubosque.modelo.Ciudadano
org.hibernate.AnnotationException: No identifier specified for entity: login.Users
java.lang.RuntimeException: org.hibernate.AnnotationException: No identifier specified for entity
Org.Hibernate.AnnotationException: No Identifier Specified For Entity I don't have a id in my table
org.hibernate.AnnotationException: No identifier specified for entity using JPA XML entity-mapping
No Identifier specified exception even when it was
How to use @Id with String Type in JPA / Hibernate?
and some more...
error :
Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.mayan.nst.server.model.PhoneNumber
IF its possible i was prefer a solution were the id will NOT be generated
Thanks you very mutch for read, and for any help