2017-08-04 8 views
0

私はresteasy jakson 3.0.17を使用しています。ここに私のオブジェクトの浮き沈みがあります。私は特定の製品のJPAのクエリを行うと、私はproductDataElementsコレクションが含まれていますが、このデータはRESTのWebサービスの呼び出しによってブラウザに送信されたときに、サーバー側の入れ子構造を取得し、私は空のオブジェクトとコレクションを取得ジャクソン3.0 @EmbededIdでオブジェクトをシリアル化することができません

@SuppressWarnings("serial") 
@Entity 
@Getter 
@Setter 
@EqualsAndHashCode 
@NoArgsConstructor 
@AllArgsConstructor 
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, 
     property = "@id") 
public class Product implements Serializable { 
    @Id 
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_seq") 
    @SequenceGenerator(name = "id_seq", sequenceName = "id_seq") 
    private Long productId; 

    @Basic 
    private String productName; 

    @Basic 
    private String type; 

    @Basic 
    private String productCode; 

    @Basic 
    private String outputName; 

    @Basic 
    private String creationMethod; 

    @LazyCollection(LazyCollectionOption.FALSE) 
    @OneToMany(mappedBy = "primaryKey.product") 
    @JsonManagedReference 
    private Set<ProductDataElement> productDataElements = new HashSet<>(); 
} 

@SuppressWarnings("serial") 
@Entity 
@Table(schema = "product", name = "productdataelement") 
// To cater to additional column in the mapping table 
@AssociationOverrides({ 
     @AssociationOverride(name = "primaryKey.product", joinColumns = @JoinColumn(name = "productId")), 
     @AssociationOverride(name = "primaryKey.dataElement", joinColumns = @JoinColumn(name = "dataElementId")), 
}) 
@Setter 
public class ProductDataElement implements Serializable { 
    @EmbeddedId 
    @JsonUnwrapped 
    private ProductDataElementId primaryKey; 

    @Basic 
    private Long rowLimit; 
} 

@SuppressWarnings("serial") 
@Getter 
@Setter 
@EqualsAndHashCode 
@NoArgsConstructor 
@AllArgsConstructor 
@Embeddable 
public class ProductDataElementId implements Serializable { 

    @JsonBackReference 
    @ManyToOne(cascade = CascadeType.ALL) 
    private Product product; 

    @JsonBackReference 
    @ManyToOne(cascade = CascadeType.ALL) 
    private DataElement dataElement; 

} 

ProductDataElementオブジェクトです。完璧なオブジェクトを得るための可能な解決策は何か?

そのは解決

答えて

0

は..私はそれが働いて得るためにProductDataElementIdとProductDataElementに

@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, 
     property = "@id") 

をAADDしなければなりませんでした。

関連する問題