openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mateusz User (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-1226) Can not merge entity with nested embeddable
Date Mon, 08 Feb 2010 14:07:27 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12830947#action_12830947
] 

Mateusz User commented on OPENJPA-1226:
---------------------------------------

In openJPA-1.2.1 version it still exist:
setters are omitted..

@Embeddable
public class Address
{
    private String street;

    private String homeNr;

    private String placeNr;

    private String city;

    private String zip;
    
    @Column(name = "street")
    public String getStreet()
    {
        return street;
    }

    @Column(name = "home_nr")
    public String getHomeNr()
    {
        return homeNr;
    }

    @Column(name = "place_nr")
    public String getPlaceNr()
    {
        return placeNr;
    }

    @Column(name = "city")
    public String getCity()
    {
        return city;
    }

    @Column(name = "zip")
    public String getZip()
    {
        return zip;
    }
}

@Embeddable
public class Invoice
{
    private String name;
    private Address address = new Address();
    private String nip;
    
    @Column(name = "invoice_name")
    public String getName()
    {
        return name;
    }
    
    @Embedded
    @AttributeOverrides({
      @AttributeOverride(name = "street",  column = @Column(name = "invoice_address_street")),
      @AttributeOverride(name = "homeNr",  column = @Column(name = "invoice_address_home_nr")),
      @AttributeOverride(name = "placeNr", column = @Column(name = "invoice_address_place_nr")),
      @AttributeOverride(name = "city",    column = @Column(name = "invoice_address_city")),
      @AttributeOverride(name = "zip",     column = @Column(name = "invoice_address_zip"))
    })
    public Address getAddress()
    {
        return address;
    }
    
    @Column(name = "invoice_nip")
    public String getNip()
    {
        return nip;
    }
}

@Entity
@Table(name = "offline_app_users_payment")
public class OfflineUserPayment extends BaseID
{
    private Date paymentDate;
    private Users user;
    private Payment payment;
    private Integer status;
    private String transaction;
    private Invoice invoice;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "payment_date")
    public Date getPaymentDate()
    {
        return paymentDate;
    }
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="user_id")
    public Users getUser()
    {
        return user;
    }
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="payment_id")
    public Payment getPayment()
    {
        return payment;
    }
    
    @Column(name = "status")
    public Integer getStatus()
    {
        return status;
    }
    
    @Column(name = "transaction_id")
    public String getTransaction()
    {
        return transaction;
    }
    
    @Embedded
    public Invoice getInvoice()
    {
        return invoice;
    }
}
Using merge on new object (should generate database insert):
OfflineUserPayment newUserPayment = new OfflineUserPayment();
        newUserPayment.setFlag(1);
        newUserPayment.setModification(Modification.currentDate());
        newUserPayment.setPayment(payment);
        newUserPayment.setPaymentDate(null);
        newUserPayment.setStatus(-1);
        newUserPayment.setUser(user);
            Invoice invoice = new Invoice();
            invoice.setName(remoteInvoice.getName());
            invoice.setNip(remoteInvoice.getNip());
            invoice.getAddress().setStreet(remoteInvoice.getStreet());
            invoice.getAddress().setHomeNr(remoteInvoice.getHomeNr());
            invoice.getAddress().setPlaceNr(remoteInvoice.getPlaceNr());
            invoice.getAddress().setCity(remoteInvoice.getCity());
            invoice.getAddress().setZip(remoteInvoice.getZip());
            newUserPayment.setInvoice(invoice);
     getEntityManager().persist(newUserPayment);

///Stacktrace:
<openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
Cannot manipulate identity of type "com.net.recepty.webservice.server.domain.Address": it's
identity type is unknown.
	at org.apache.openjpa.kernel.StateManagerImpl.<init>(StateManagerImpl.java:162)
	at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2653)
	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:93)
	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
	at org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:202)
	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:153)
	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
	at org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:202)
	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:153)
	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
	at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3212)
	at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1158)
	at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:769)

> Can not merge entity with nested embeddable
> -------------------------------------------
>
>                 Key: OPENJPA-1226
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1226
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>            Reporter: Fay Wang
>             Fix For: 2.0.0-M3
>
>
> When an entity has nested embeddables, the merge operation fails with the following exception:
> org.apache.openjpa.persistence.ArgumentException:
> Cannot manipulate identity of type "com.ibm.wssvt.acme.annuity.common.bean.jpa.Address":
it's identity type is unknown.
>         at org.apache.openjpa.kernel.StateManagerImpl.<init>(StateManagerImpl.java:173)
>         at org.apache.openjpa.kernel.BrokerImpl.embed(BrokerImpl.java:2770)
>         at org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:106)
>         at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:251)
>         at org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:244)
>         at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:251)
>         at org.apache.openjpa.kernel.AttachStrategy.attachMap(AttachStrategy.java:462)
>         at org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:269)
>         at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:251)
>         at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:104)
>         at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3346)
>         at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1176)
>         at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:852)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message