openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schmidt <fakod...@googlemail.com>
Subject Re: general issue with ManyToOne relations as primary key attributes?
Date Mon, 14 Feb 2011 10:24:49 GMT
Additional Info:

Works fine if I remove the ManyToOne relation.

public class ObjectItemStatus {
    . . .
    @Id
    @Column(name = "obj_item_id", nullable = false, updatable = false)
    protected BigInteger objItem;
   . . .
}

Shouldn't that work?


On Mon, Feb 14, 2011 at 10:48 AM, Christopher Schmidt <
fakod666@googlemail.com> wrote:

> Hi all, is there in general an issue with ManyToOne relations as primary
> key attributes?
>
> In the example below, I get an exception (of course cfeat_stat_id should
> not be null):
> org.apache.openjpa.persistence.PersistenceException: FEHLER: NULL-Wert in
> Spalte »cfeat_stat_id« verletzt Not-Null-Constraint {prepstmnt 578065504
> INSERT INTO cfeat_stat (cfeat_stat_id, obj_item_stat_ix,
>         cbrn_thrt_lvl_code, creator_id, update_seqnr, invstg_stat_code,
>         security_stat_code, usage_stat_code)
>
> I added the two insert statements and the entity classes below....
>
>
> Christopher
>
>
> INSERT INTO obj_item_stat (obj_item_stat_ix, obj_item_id, creator_id,
>         update_seqnr, booby_trap_prsnc_code, emsn_ctrl_code, cat_code,
>         rptd_id)
>     VALUES (?, ?, ?, ?, ?, ?, ?, ?)
> [params=(BigDecimal) 18510600000000000007, (BigDecimal)
> 18510600000000000230, (BigDecimal) 18510600000000000000, (long) 0, (null)
> null, (null) null, (String) CF, (BigDecimal) 18510600000000000217]
>
> INSERT INTO cfeat_stat (cfeat_stat_id, obj_item_stat_ix,
>         cbrn_thrt_lvl_code, creator_id, update_seqnr, invstg_stat_code,
>         security_stat_code, usage_stat_code)
>     VALUES (?, ?, ?, ?, ?, ?, ?, ?)
> [params=(null) null, (BigDecimal) 18510600000000000007, (null) null,
> (BigDecimal) 18510600000000000000, (long) 0, (null) null, (null) null,
> (null) null]
>
>
>
>
>
> @Entity
> @Table(name = "obj_item_stat")
> @Inheritance(strategy=InheritanceType.JOINED)
> @IdClass(ObjectItemStatus.ObjectItemStatusId.class)
> public class ObjectItemStatus {
>
>     @Id
>     @Column(name = "obj_item_stat_ix", nullable = false, length = 20)
>     protected BigInteger ix;
>
>     @Id
>     @ManyToOne(fetch = FetchType.EAGER)
>     @JoinColumn(name = "obj_item_id", nullable = false, updatable = false)
>     protected ObjectItem objItem;
>
>
> public static class ObjectItemStatusId implements Serializable {
>         public BigInteger ix;
>         public BigInteger objItem;
> . . .
> }
> }
>
> @Entity
> @Table(name = "cfeat_stat")
> @PrimaryKeyJoinColumns({
>         @PrimaryKeyJoinColumn(name = "cfeat_stat_id", referencedColumnName
> = "obj_item_id"),
>         @PrimaryKeyJoinColumn(name = "obj_item_stat_ix",
> referencedColumnName = "obj_item_stat_ix")})
> public class ControlFeatureStatus extends ObjectItemStatus {
> . . .
> }
>
> --
> Christopher
> twitter: @fakod
> blog: http://blog.fakod.eu
>
>


-- 
Christopher
twitter: @fakod
blog: http://blog.fakod.eu

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message