[jboss-user] [EJB 3.0] - Re: ERM to Entity relationship problem
te-bachi
do-not-reply at jboss.com
Fri Jan 26 07:52:29 EST 2007
Third approach:
Exception:
| javax.persistence.PersistenceException: org.hibernate.MappingException: Repeated column in mapping for entity: gis.audit.entity.AuditSearchAssignEntity column: CRITERIA_ID (should be mapped with insert="false" update="false")
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:698)
| at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
| at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
| [...]
|
Assign PK:
| @Embeddable
| public class AuditSearchAssignPK implements Serializable {
| private BigInteger criteriaId;
| private BigInteger templateId;
|
| public AuditSearchAssignPK() {
| //
| }
|
| public AuditSearchAssignPK(BigInteger criteriaId, BigInteger templateId) {
| this.criteriaId = criteriaId;
| this.templateId = templateId;
| }
|
| @Column(name = "CRITERIA_ID", nullable = false, length = 38)
| public BigInteger getCriteriaId() {
| return criteriaId;
| }
|
| public void setCriteriaId(BigInteger criteriaId) {
| this.criteriaId = criteriaId;
| }
|
| @Column(name = "TEMPLATE_ID", nullable = false, length = 38)
| public BigInteger getTemplateId() {
| return templateId;
| }
|
| public void setTemplateId(BigInteger templateId) {
| this.templateId = templateId;
| }
|
| public boolean equals(Object obj) {
| if (this == obj) return true;
| if (obj == null || getClass() != obj.getClass()) return false;
|
| AuditSearchAssignPK that = (AuditSearchAssignPK) obj;
|
| if (criteriaId != null ? !criteriaId.equals(that.criteriaId) : that.criteriaId != null) return false;
| if (templateId != null ? !templateId.equals(that.templateId) : that.templateId != null) return false;
|
| return true;
| }
|
| public int hashCode() {
| return criteriaId.hashCode() + templateId.hashCode();
| }
| }
|
Assign Entity:
| @Entity(name = "AuditSearchAssignEntity")
| @Table(schema = "UGIS1004", name = "GIS_T_AUDIT_SEARCH_ASSIGN")
| public class AuditSearchAssignEntity {
| private AuditSearchAssignPK pk;
| private BigInteger criteriaOrder;
| private BigInteger isSpecific;
| private AuditSearchCriteriaEntity criteriaId;
| private AuditSearchTemplateEntity templateId;
|
| @EmbeddedId
| public AuditSearchAssignPK getPk() {
| return pk;
| }
|
| public void setPk(AuditSearchAssignPK pk) {
| this.pk = pk;
| }
|
| @ManyToOne
| @JoinColumn(name = "CRITERIA_ID", referencedColumnName = "CRITERIA_ID", nullable = false)
| public AuditSearchCriteriaEntity getCriteriaId() {
| return criteriaId;
| }
|
| public void setCriteriaId(AuditSearchCriteriaEntity criteriaId) {
| this.criteriaId = criteriaId;
| }
|
| @ManyToOne
| @JoinColumn(name = "TEMPLATE_ID", referencedColumnName = "TEMPLATE_ID", nullable = false)
| public AuditSearchTemplateEntity getTemplateId() {
| return templateId;
| }
|
| public void setTemplateId(AuditSearchTemplateEntity templateId) {
| this.templateId = templateId;
| }
|
| @Column(name = "CRITERIA_ORDER", nullable = false, length = 4)
| public BigInteger getCriteriaOrder() {
| return criteriaOrder;
| }
|
| public void setCriteriaOrder(BigInteger criteriaOrder) {
| this.criteriaOrder = criteriaOrder;
| }
|
| @Column(name = "IS_SPECIFIC", nullable = false, length = 1)
| public BigInteger getIsSpecific() {
| return isSpecific;
| }
|
| public void setIsSpecific(BigInteger specific) {
| isSpecific = specific;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4006784#4006784
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4006784
More information about the jboss-user
mailing list