8 Replies Latest reply on Jan 30, 2007 6:00 AM by Andreas Bachmann

    ERM to Entity relationship problem

    Andreas Bachmann Newbie

      I was developing a C/C++ application and I want to migrate this application to Java EE 5 / EJB 3.0.
      I use an oracle database to do persistency. I create 3 entities and mapped it via annotation to a relational database.
      My ERM can't be changed anymore, but all this relationship types in the book "EJB 3.0" written by Bill Burke can't applied.

      Environment:
      o Java 1.5.0_09
      o IntelliJ IDEA 6.0.4
      o JBoss 4.0.5 AS (JEMS Installer with ejb3)
      o Windows XP SP2
      o Oracle 10.1.0.4.0 (Solaris 8)

      ERM:


      Independent Code:

      Client (Struts Action):

      public class PaymentSearchAction extends Action {
       public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
       StringBuffer buffer = new StringBuffer();
      
       try {
       InitialContext ctx = new InitialContext();
       UserTransaction trans = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
       trans.begin();
       AuditSearch search = (AuditSearch) ctx.lookup("JApollo/AuditSearchBean/local");
       AuditSearchTemplateEntity templ = search.getTemplate(BigInteger.valueOf(1));
      
       buffer.append("id: ");
       buffer.append(templ.getTemplateId());
      
       buffer.append("key: ");
       buffer.append(templ.getKey());
      
       buffer.append("<br>");
      
       List<AuditSearchAssignEntity> searchAssignList = templ.getSearchAssignList(); // <== Exception raised!
       AuditSearchAssignEntity searchAssign;
       AuditSearchCriteriaEntity criteria;
       for (int i = 0; i < searchAssignList.size(); i++) {
       searchAssign = searchAssignList.get(i);
       criteria = searchAssign.getCriteria();
      
       buffer.append("id: ");
       buffer.append(criteria.getCriteriaId());
      
       buffer.append("is-splitted: ");
       buffer.append(criteria.getIsSplitted());
      
       buffer.append("key: ");
       buffer.append(criteria.getKey());
      
       buffer.append("type: ");
       buffer.append(criteria.getType());
      
       buffer.append("<br>");
       }
       trans.commit();
       } catch (Exception e) {
       buffer.append("Error: ");
       buffer.append(e.getMessage());
       e.printStackTrace();
       }
      
       request.setAttribute("test", buffer.toString());
      
       return mapping.getInputForward();
       }
      }
      


      Stateless Session Bean:
      @Stateless
      public class AuditSearchBean implements AuditSearch {
       @PersistenceContext
       EntityManager em;
      
       public AuditSearchTemplateEntity getTemplate(BigInteger id) {
       return em.find(AuditSearchTemplateEntity.class, id);
       }
      }
      


      Template Entity:
      @Entity(name = "AuditSearchTemplateEntity")
      @Table(schema = "UGIS1004", name = "GIS_T_AUDIT_SEARCH_TEMPL")
      public class AuditSearchTemplateEntity {
       private BigInteger templateId;
       private BigInteger key;
       private List<AuditSearchAssignEntity> auditSearchAssignEntities;
      
       @Id
       @Column(name = "TEMPLATE_ID", nullable = false, length = 38)
       public BigInteger getTemplateId() {
       return templateId;
       }
      
       public void setTemplateId(BigInteger templateId) {
       this.templateId = templateId;
       }
      
       @Column(name = "KEY", nullable = false, length = 4)
       public BigInteger getKey() {
       return key;
       }
      
       public void setKey(BigInteger key) {
       this.key = key;
       }
      
       @OneToMany(mappedBy = "templateId")
       public List<AuditSearchAssignEntity> getAuditSearchAssignEntities() {
       return auditSearchAssignEntities;
       }
      
       public void setAuditSearchAssignEntities(List<AuditSearchAssignEntity> auditSearchAssignEntities) {
       this.auditSearchAssignEntities = auditSearchAssignEntities;
       }
      
       public boolean equals(Object o) {
       if (this == o) return true;
       if (o == null || getClass() != o.getClass()) return false;
      
       AuditSearchTemplateEntity that = (AuditSearchTemplateEntity) o;
      
       if (templateId != null ? !templateId.equals(that.templateId) : that.templateId != null) return false;
      
       return true;
       }
      
       public int hashCode() {
       return (templateId != null ? templateId.hashCode() : 0);
       }
      }
      


      Criteria Entity:
      @Entity(name = "AuditSearchCriteriaEntity")
      @Table(schema = "UGIS1004", name = "GIS_T_AUDIT_SEARCH_CRIT")
      public class AuditSearchCriteriaEntity {
       private BigInteger criteriaId;
       private BigInteger key;
       private BigInteger type;
       private BigInteger isSplitted;
       private List<AuditSearchAssignEntity> auditSearchAssignEntities;
      
       @Id
       @Column(name = "CRITERIA_ID", nullable = false, length = 38)
       public BigInteger getCriteriaId() {
       return criteriaId;
       }
      
       public void setCriteriaId(BigInteger criteriaId) {
       this.criteriaId = criteriaId;
       }
      
       @Column(name = "KEY", nullable = false, length = 4)
       public BigInteger getKey() {
       return key;
       }
      
       public void setKey(BigInteger key) {
       this.key = key;
       }
      
       @Column(name = "TYPE", nullable = false, length = 4)
       public BigInteger getType() {
       return type;
       }
      
       public void setType(BigInteger type) {
       this.type = type;
       }
      
       @Column(name = "IS_SPLITTED", nullable = false, length = 1)
       public BigInteger getIsSplitted() {
       return isSplitted;
       }
      
       public void setIsSplitted(BigInteger splitted) {
       isSplitted = splitted;
       }
      
       @OneToMany(mappedBy = "criteriaId")
       public List<AuditSearchAssignEntity> getAuditSearchAssignEntities() {
       return auditSearchAssignEntities;
       }
      
       public void setAuditSearchAssignEntities(List<AuditSearchAssignEntity> auditSearchAssignEntities) {
       this.auditSearchAssignEntities = auditSearchAssignEntities;
       }
      
       public boolean equals(Object o) {
       if (this == o) return true;
       if (o == null || getClass() != o.getClass()) return false;
      
       AuditSearchCriteriaEntity that = (AuditSearchCriteriaEntity) o;
      
       if (criteriaId != null ? !criteriaId.equals(that.criteriaId) : that.criteriaId != null) return false;
      
       return true;
       }
      
       public int hashCode() {
       return (criteriaId != null ? criteriaId.hashCode() : 0);
       }
      }
      


        • 1. Re: ERM to Entity relationship problem
          Andreas Bachmann Newbie

          First approach:

          Exception:

          org.hibernate.AnnotationException: No identifier specified for entity: gis.audit.entity.AuditSearchAssignEntity
           at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:626)
           at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
           at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
           at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
           at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
           at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
           at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
           at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
           [...]
          


          Assign Entity:
          @Entity(name = "AuditSearchAssignEntity")
          @Table(schema = "UGIS1004", name = "GIS_T_AUDIT_SEARCH_ASSIGN")
          public class AuditSearchAssignEntity {
           private BigInteger criteriaOrder;
           private BigInteger isSpecific;
           private AuditSearchCriteriaEntity criteriaId;
           private AuditSearchTemplateEntity templateId;
          
           @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;
           }
          }
          


          • 2. Re: ERM to Entity relationship problem
            Andreas Bachmann Newbie

            Second approach:

            Same problem here: mappedBy reference an unknown target entity property

            Exception:

            org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: gis.audit.entity.AuditSearchAssignEntity.criteriaId in gis.audit.entity.AuditSearchCriteriaEntity.auditSearchAssignEntities
             at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:506)
             at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
             at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
             at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
             at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
             at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
             at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
             at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
             at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
             at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
             at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
             at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
             [...]
            



            Assign PK:
            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;
             }
            
             public BigInteger getCriteriaId() {
             return criteriaId;
             }
            
             public void setCriteriaId(BigInteger criteriaId) {
             this.criteriaId = criteriaId;
             }
            
             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")
            @IdClass(AuditSearchAssignPK.class)
            public class AuditSearchAssignEntity {
             private BigInteger criteriaOrder;
             private BigInteger isSpecific;
             private AuditSearchCriteriaEntity criteriaId;
             private AuditSearchTemplateEntity templateId;
            
             @Id
             @ManyToOne
             @JoinColumn(name = "CRITERIA_ID", referencedColumnName = "CRITERIA_ID", nullable = false)
             public AuditSearchCriteriaEntity getCriteriaId() {
             return criteriaId;
             }
            
             public void setCriteriaId(AuditSearchCriteriaEntity criteriaId) {
             this.criteriaId = criteriaId;
             }
            
             @Id
             @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;
             }
            }
            


            • 3. Re: ERM to Entity relationship problem
              Andreas Bachmann Newbie

              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;
               }
              }
              


              • 4. Re: ERM to Entity relationship problem
                Andreas Bachmann Newbie

                Fourth approach:

                Exception:

                12:20:59,153 INFO [STDOUT] Hibernate: select auditsearc0_.TEMPLATE_ID as TEMPLATE1_23_0_, auditsearc0_.KEY as KEY23_0_ from UGIS1004.GIS_T_AUDIT_SEARCH_TEMPL auditsearc0_ where auditsearc0_.TEMPLATE_ID=?
                12:20:59,449 INFO [STDOUT] Hibernate: select auditsearc0_.templateId_TEMPLATE_ID as templateId6_2_, auditsearc0_.CRITERIA_ID as CRITERIA1_2_, auditsearc0_.TEMPLATE_ID as TEMPLATE2_2_, auditsearc0_.CRITERIA_ID as CRITERIA1_21_1_, auditsearc0_.TEMPLATE_ID as TEMPLATE2_21_1_, auditsearc0_.criteriaId_CRITERIA_ID as criteriaId5_21_1_, auditsearc0_.templateId_TEMPLATE_ID as templateId6_21_1_, auditsearc0_.CRITERIA_ORDER as CRITERIA3_21_1_, auditsearc0_.IS_SPECIFIC as IS4_21_1_, auditsearc1_.CRITERIA_ID as CRITERIA1_22_0_, auditsearc1_.KEY as KEY22_0_, auditsearc1_.TYPE as TYPE22_0_, auditsearc1_.IS_SPLITTED as IS4_22_0_ from UGIS1004.GIS_T_AUDIT_SEARCH_ASSIGN auditsearc0_ inner join UGIS1004.GIS_T_AUDIT_SEARCH_CRIT auditsearc1_ on auditsearc0_.criteriaId_CRITERIA_ID=auditsearc1_.CRITERIA_ID where auditsearc0_.templateId_TEMPLATE_ID=?
                12:20:59,496 WARN [JDBCExceptionReporter] SQL Error: 904, SQLState: 42000
                12:20:59,496 ERROR [JDBCExceptionReporter] ORA-00904: "AUDITSEARC0_"."CRITERIAID_CRITERIA_ID": ungültiger Bezeichner
                
                12:20:59,496 ERROR [STDERR] org.hibernate.exception.SQLGrammarException: could not initialize a collection: [gis.audit.entity.AuditSearchTemplateEntity.auditSearchAssignEntities#1]
                 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
                 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
                 at org.hibernate.loader.Loader.loadCollection(Loader.java:1925)
                 [...]
                


                @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(referencedColumnName = "CRITERIA_ID", nullable = false)
                 public AuditSearchCriteriaEntity getCriteriaId() {
                 return criteriaId;
                 }
                
                 public void setCriteriaId(AuditSearchCriteriaEntity criteriaId) {
                 this.criteriaId = criteriaId;
                 }
                
                 @ManyToOne
                 @JoinColumn(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;
                 }
                }
                


                • 5. Re: ERM to Entity relationship problem
                  Andreas Bachmann Newbie

                   

                  "te-bachi" wrote:

                   List<AuditSearchAssignEntity> searchAssignList = templ.getSearchAssignList(); // <== Exception raised!
                   AuditSearchAssignEntity searchAssign;
                   AuditSearchCriteriaEntity criteria;
                   for (int i = 0; i < searchAssignList.size(); i++) {
                   searchAssign = searchAssignList.get(i);
                   criteria = searchAssign.getCriteria();
                  



                  sorry... should be:

                   List<AuditSearchAssignEntity> searchAssignList = templ.getAuditSearchAssignEntities();
                   AuditSearchAssignEntity searchAssign;
                   AuditSearchCriteriaEntity criteria;
                   for (int i = 0; i < searchAssignList.size(); i++) {
                   searchAssign = searchAssignList.get(i);
                   criteria = searchAssign.getCriteriaId();
                  


                  • 6. Re: ERM to Entity relationship problem
                    Andreas Bachmann Newbie

                    Fifth approach:

                    org.hibernate.AnnotationException: com.ubs.gis.audit.entity.AuditSearchAssignPK has no persistent id property
                     at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1702)
                     at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1171)
                     at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:706)
                     at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
                     at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
                     at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
                     at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
                     at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
                     at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
                     at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
                     at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
                     at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
                    [...]
                    


                    Assign PK:
                    @Embeddable
                    public class AuditSearchAssignPK implements Serializable {
                     //
                    }
                    


                    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;
                     }
                    }
                    




                    • 7. Re: ERM to Entity relationship problem
                      Andrew Dale Newbie

                      Hi,

                      The problem with you first appraoch is the you have an entity ( AuditSearchAssignEntity) with no @Id declared in it.

                      Cheers,

                      Andy

                      • 8. Re: ERM to Entity relationship problem
                        Andreas Bachmann Newbie

                         

                        "andydale" wrote:
                        The problem with you first appraoch is the you have an entity ( AuditSearchAssignEntity) with no @Id declared in it.

                        Yeah... I know this.
                        But what is the solution?
                        In the second approach (see third post), I added the @Id tag to the two foreign keys (Composite Key), because no primary key is on the table.
                        But it doesn't help.

                        Any other comments?
                        Every help is welcome.