2011-12-22 2 views
0

まず、長い投稿のためのお話、私はできるだけそれをカットしようとしました。JPAはオブジェクトを永続させるときにフィールドを逃します

JPAを使用してオブジェクトを永続化しようとしています。ほとんどのオブジェクトフィールドは永続化されますが、完全にスキップされますが、エラーはスローされません。

つまり、私はListedItemDetailのインスタンスを永続化しようとしています。残念ながら、BidCollectionフィールドは完全に無視されており、データベースにそのフィールドのトレースはありません。理由はわかりません。

私はrelaventソースを含めました。ソースはサードパーティのスキーマから生成されました。私はJPAマッピングのためにorm.xmlを使用しており、以下のreaventビットも含めています。

public class ListedItemDetail extends Item implements Serializable{ 
    protected BidCollection bids; 
} 

public class Item extends ExtensibleDataObject implements Serializable { 
    protected int listingId; 
} 

public class BidCollection extends PagedCollectionOfBidte0R55Be implements 
Serializable{ 
    private final static long serialVersionUID = 1L; 
} 

public class PagedCollectionOfBidte0R55Be implements Serializable { 
    private final static long serialVersionUID = 1L; 
    protected Integer totalCount; 
    protected Integer page; 
    protected Integer pageSize; 
    protected InnerCollectionOfBidte0R55Be list; 
} 

public class InnerCollectionOfBidte0R55Be implements Serializable { 
    private final static long serialVersionUID = 1L; 
    protected List<Bid> bid; 
} 

public class Bid extends ExtensibleDataObject implements Serializable { 
    private final static long serialVersionUID = 1L; 
    protected String account; 
    protected Boolean isByMobile; 
    protected Boolean isByProxy; 
    protected Timestamp bidDate; 
    protected Boolean isBuyNow; 
    protected Member bidder; 
} 

orm.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<entity-mappings version="2.0"> 
<entity class="nz.co.trademe.api.v1.ListedItemDetail"> 
    <attributes> 
     <cascade> 
      <cascade-persist/> 
     </cascade> 
     <embedded name="bids"> 
     </embedded> 
    </attributes> 
</entity> 

<entity class="nz.co.trademe.api.v1.Item"> 
    <inheritance strategy="JOINED"/> 
    <discriminator-column discriminator-type="STRING"/> 
    <attributes> 
     <id name="listingId"> 
     </id> 
    </attributes> 
</entity> 


<embeddable class="nz.co.trademe.api.v1.PagedCollectionOfBidte0R55Be"> 
</embeddable> 

<embeddable class="nz.co.trademe.api.v1.InnerCollectionOfBidte0R55Be"> 
    <attributes> 
     <element-collection name="bid"> 
     </element-collection> 
    </attributes> 
</embeddable> 

<embeddable class="nz.co.trademe.api.v1.Bid"> 
</embeddable> 

<embeddable class="nz.co.trademe.api.v1.BidCollection"> 
</embeddable> 
</entity-mappings> 

答えて

3

問題が組み込み可能であることと継承を使用してBidCollectionに関連しています。 JPAは埋め込み可能なものでの継承をサポートしていません。

技術的には、EclipseLinkは埋め込み可能なオブジェクトで継承をサポートしていますが、JPAアノテーションでは現在のところサポートされていません。

継承を削除するか、DescriptorCustomizerを使用して継承を設定することができます。

あなたのモデルも非常に畳み込まれているように見えますが、あなたはそれを再考したいかもしれません。

+0

モデルが畳み込まれています。サードパーティAPIのスキーマが原因です。ご回答有難うございます;それは私に多くの時間を節約しました。 – Kevin

関連する問題