Hi,

trying to narrow it down myself and asking if i am right: Can it be that i need 
to manually manage the inverse relationship before persist?

This would mean that i need to do something like that before persisting:

        for(DeliveryAddress dAddress : order.getDeliveryAddresses()) {
            dAddress.setOrder(order);
        }

Looks weird because i thought the provider can do this magic for me :-)

---
regards
Marc Logemann
http://www.logemann.org
http://www.logentis.de




Am 16.09.2010 um 15:43 schrieb Marc Logemann:

> Hi,
> 
> i am getting crazy. Hope someone can point me to the right spot. Suppose the 
> following tables:
> 
> DB-Table: orders
> --------
> oid int
> ...
> 
> 
> DB-Table: Adress
> ----------
> oid int
> order_oid
> 
> 
> 
> Now my classes:
> 
> @Entity
> @Table(name = "orders")
> public class Order {
>    @Id
>    @GeneratedValue(strategy = GenerationType.IDENTITY)
>    @Column(name = "oid")
>    int oid;
> 
>    @OneToMany(mappedBy = "order", fetch = FetchType.EAGER, cascade = 
> CascadeType.ALL)
>    List<DeliveryAddress> deliveryAddresses;
>    ....
> })
> 
> @Entity
> public class DeliveryAddress extends Address {
>     .... (Id and Table annotation from superclass. Id field is also "oid")
> 
>    @ManyToOne(cascade = CascadeType.ALL)
>    @JoinColumn(name="order_oid", referencedColumnName="oid")
>    Order order;
> }
> 
> 
> Now when i persist my order table, everything is fine but the foreign key 
> "order_oid" inside the address table is null. Same goes on for other mappings 
> as well. Whats the problem here?
> 
> Thanks.
> 
> ---
> regards
> Marc Logemann
> http://www.logemann.org
> http://www.logentis.de
> 
> 
> 
> 

Reply via email to