Results 1 to 2 of 2
  1. #1
    zigzag is offline Member
    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    0

    Unhappy Hibernate mapping error Provided id of the wrong type with composite ID

    Hello every one, I try to map two model class by anotation but I caugth this error

    Java Code:
    [B]Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class com.datam.xplorer.model.MpausrPK, got class com.datam.xplorer.model.MpuserPK
            at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:86)[/B]
    here my class

    MpuserPK
    Java Code:
    @Embeddable
    public class MpuserPK implements Serializable {
        @Column(name = "M0DIVI", nullable = false)
        private String m0divi;
        @Column(name = "M0USID", nullable = false)
        
        private String m0usid;
    
        public MpuserPK() {
        }
    
    //some getter and setter method
    }
    Mpuser
    Java Code:
    public class Mpuser implements Serializable {
        private static final long serialVersionUID = 1L;
        @EmbeddedId
        protected MpuserPK mpuserPK;
        @Column(name = "M0CONO", nullable = false)
        private short m0cono;
        @Column(name = "M0USPW", nullable = false)
        private String m0uspw;
        @Column(name = "M0USTA", nullable = false)
        private char m0usta;
        @Column(name = "M0PICT", nullable = false)
        private String m0pict;
        [B]@OneToOne(cascade = CascadeType.ALL, mappedBy = "mpuser",targetEntity=com.datam.xplorer.model.Mpausr.class)
        private Mpausr mpausr = new Mpausr();[/B]
    
        public Mpuser() {
        }
    
        public Mpuser(MpuserPK mpuserPK) {
            this.mpuserPK = mpuserPK;
        }
    
    //some getter and setter method
    }
    MpausrPK
    Java Code:
    @Embeddable
    public class MpausrPK implements Serializable {
        @OneToOne
        @Column(name = "M1DIVI", nullable = false)
        private String m1divi;
        @Column(name = "M1USID", nullable = false)
        private String m1usid;
    
        public MpausrPK() {
        }
    //some getter and setter method
    }
    Mpausr
    Java Code:
    @Entity
    @Table(name = "MPAUSR", schema="MTHJDTA")
    public class Mpausr implements Serializable {
        private static final long serialVersionUID = 1L;
        @EmbeddedId
        protected MpausrPK mpausrPK;
        @Column(name = "M1CONO", nullable = false)
        private short m1cono;
        @Column(name = "M1AMIN", nullable = false)
        private BigDecimal m1amin;
        @Column(name = "M1AMAX", nullable = false)
        private BigDecimal m1amax;
        @Column(name = "M1POSI", nullable = false)
        private String m1posi;
        @Column(name = "M1PRIO", nullable = false)
        private int m1prio;
        @Column(name = "M1ORT1", nullable = false)
        private String m1ort1;
        @Column(name = "M1ORT2", nullable = false)
        private String m1ort2;
        @Column(name = "M1ORT3", nullable = false)
        private String m1ort3;
        @Column(name = "M1ORT4", nullable = false)
        private String m1ort4;
        @Column(name = "M1ORT5", nullable = false)
        private String m1ort5;
        @Column(name = "M1ORT6", nullable = false)
        private String m1ort6;
        @Column(name = "M1ORT7", nullable = false)
        private String m1ort7;
        @Column(name = "M1ORT8", nullable = false)
        private String m1ort8;
        @Column(name = "M1ORTY", nullable = false)
        private char m1orty;
        @Column(name = "M1STAT", nullable = false)
        private char m1stat;
        @Column(name = "M1LEVL", nullable = false)
        private char m1levl;
    [B]    @JoinColumns({@JoinColumn(name = "M1DIVI", referencedColumnName = "M0DIVI", insertable = false, updatable = false), @JoinColumn(name = "M1USID", referencedColumnName = "M0USID", insertable = false, updatable = false)})
        @OneToOne
        private Mpuser mpuser;[/B]
    
        public Mpausr() {
        }
    
        public Mpausr(MpausrPK mpausrPK) {
            this.mpausrPK = mpausrPK;
        }
    
    }
    and I can't chage table structure.
    please any one help me :eek:
    Last edited by zigzag; 08-08-2008 at 08:40 AM.

  2. #2
    lcaffe is offline Member
    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Default Same problem.

    Dear I get the same problem!
    Did you resolve? How?

    Best regards,
    Leonardo

Similar Threads

  1. composite-id problem hibernate
    By javadev in forum JDBC
    Replies: 14
    Last Post: 07-27-2009, 07:30 PM
  2. Replies: 1
    Last Post: 05-07-2008, 05:05 PM
  3. composite key Hibernate
    By Problem in forum Web Frameworks
    Replies: 0
    Last Post: 07-25-2007, 12:13 PM
  4. composite-id and hibernate
    By Marty in forum JDBC
    Replies: 1
    Last Post: 05-28-2007, 05:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •