-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Help set oneToMany bidirectional relationship.
PostPosted: Thu Oct 11, 2007 1:01 pm 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:11 am
Posts: 22
Hi all
I need help setting oneToMany bidirectional relationship.
My entities are CUSTOMER and ORDER, each customer have several orders,
From each order I would like to be able to get the customer.

I get this exception on build:

AnnotationException: mappedBy reference an unknown target entity property: com.company.model.OrderEntity.customerEntity in com.company.model.CustomerEntity.OrderEntity

Please advise
Sharon

Customer Entity:
Code:
@Entity
@Table(name = "CustomerEntity")
public class CustomerEntity{

            private Long customerId;
            String name;
            String code;

            //List of children (OrderEntity)
            private List<OrderEntity> orderEntityList;


            //I removed all other getters / setters
     

            @OneToMany(mappedBy="customerEntity",targetEntity=OrderEntity.class,fetch=FetchType.LAZY,cascade=CascadeType.MERGE)
          @Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
            public List<OrderEntity> getOrderEntity() {
                        return orderEntityList;
            }

            public void setOrderEntity(List<OrderEntity> orderEntityList){
                        this.orderEntityList =orderEntityList ;
            }
}


Order Entity:

Code:
@Entity
@Table(name = "OrderEntity")
public class OrderEntity {

            private Long orderId;
            private List<Products> prodCodes;
           
            // Parent
            private CustomerEntity customerEntity;

            //I removed all other getters / setters   

         @ManyToOne
         @JoinColumn(name="customerId", nullable=false)
         public CustomerEntity getCustomerEntity () {
            return customerEntity;
         }

         public void setCustomerEntity(CustomerEntity customerEntity) {
            this.customerEntity = customerEntity;
         }
}


Hibernate Tool Error:

[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.company.model.OrderEntity.customerEntity in com.company.model.CustomerEntity.OrderEntity
[hibernatetool] org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.company.model.OrderEntity.customerEntity in com.company.model.CustomerEntity.OrderEntity

Code:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.