Hi,
I have an easy hibernate question. I am getting the following error:
Code:
org.hibernate.MappingException: Could not determine type for: Long, at table: PERSON, for columns: [org.hibernate.mapping.Column(ID)]
I am using annotations only for my application; so I have no hbm.xml files. Is there a way to specify the mapping type in the Column annotation? Is my only option is to use a hbm.xml file to specify this?
BTW, my annotated class looks like this:
Code:
package com.aviall.edi.jedi.persistence.commons.vo.hibernate;
import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import com.aviall.commons.vo.model.api.IEmailAddressVO;
import com.aviall.commons.vo.model.api.IPersonVO;
import com.aviall.edi.jedi.persistence.commons.models.BaseEntityModel;
@javax.persistence.Entity
//@AttributeOverride(name = "id", column = @Column(name = "ID", nullable=false, updatable=false, insertable=false))
@Table(name = "PERSON")
@NamedQueries( {
@NamedQuery(name = "PersonHibernateVO.findByFirstName", query = "select p from PersonHibernateVO p where p.firstName = ?"),
@NamedQuery(name = "PersonHibernateVO.findByLastName", query = "select p from PersonHibernateVO p where p.lastName = ?") })
public class PersonHibernateVO extends BaseEntityModel implements IPersonVO {
private static final long serialVersionUID = 1L;
@SequenceGenerator(name="generator", sequenceName="PERSON_SEQ")
@Id @GeneratedValue(strategy=SEQUENCE, generator="generator")
@Column(name="ID", unique=true, nullable=false, updatable=false, insertable=false)
private Long id;
@Column(name = "FIRST_NAME", nullable = false, length = 100)
private String firstName;
@Column(name = "MIDDLE_NAME", nullable = false, length = 100)
private String middleName;
@Column(name = "LAST_NAME", nullable = false, length = 100)
private String lastName;
@org.hibernate.annotations.CollectionOfElements(
targetElement = com.aviall.edi.jedi.persistence.commons.vo.hibernate.EmailAddressHibernateVO.class
)
@JoinTable(name = "PERSON_EMAIL_ADDRESS", joinColumns = @JoinColumn(name = "PERSON_ID"))
private Set<IEmailAddressVO> emailAddresses = new HashSet<IEmailAddressVO>();
@SuppressWarnings("unused")
public PersonHibernateVO(){}
public PersonHibernateVO(String firstName, String middleName,
String lastName, Set<IEmailAddressVO> emailAddresses,
String createdBy, Date createdDate, String updatedBy,
Date updatedDate) {
super(createdBy, createdDate, updatedBy, updatedDate);
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.emailAddresses = emailAddresses;
}
public Long getId(){
return id;
}
public void setId(Long id){
this.id = id;
}
@Override
public String getFirstName() {
return firstName;
}
@Override
public String getLastName() {
return lastName;
}
@Override
public String getMiddleName() {
return middleName;
}
@Override
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Override
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
@Override
public Set<IEmailAddressVO> getEmailAddresses() {
return emailAddresses;
}
@Override
public void setEmailAddresses(Set<IEmailAddressVO> emailAddresses) {
this.emailAddresses = emailAddresses;
}
}
Thanks!