-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Audited class with JoinColumn referencedColumnName not pk
PostPosted: Mon Feb 07, 2011 10:45 am 
Newbie

Joined: Mon Feb 07, 2011 8:36 am
Posts: 1
Hi all,

I have a Audited class with a @ManyToOne join between two tables using a non pk column, like this:

Code:
@Audited
@Entity
public class A {
   
    @Id
    @GeneratedValue
    private long id;
   
    @ManyToOne
    @JoinColumn(name = "B_TYPE", referencedColumnName="type")
    private B b;

   
    public A() {
    }

    public long getId() {
        return this.id;
    }

    public B getB() {
        return this.b;
    }

}

@Audited
@Entity
public class B {
   
    @Id
    @GeneratedValue
    private long id;
   
   
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private BType type;

   
    protected B() {
    }

    public long getId() {
        return this.id;
    }

    public BType getType() {
        return this.type;
    }

}


When I generate the database schema I get the following:


Code:
    create table A_H (
        ID number(19,0) not null,
        REV number(19,0) not null,
        REVTYPE number(3,0),
        B_TYPE number(19,0),
        primary key (ID, REV)
    );

    create table A (
        ID number(19,0) not null,
        B_TYPE varchar2(255 char),
        primary key (ID)
    );


For the "A" entity, the generated B_TYPE column has different columns types.
For the operational table it's using the non pk column, as mapped with the referencedColumnName, but for the audited table it seems that the pk it's used.

Is there any thing I can do to change this behaviour, so that for both tables, B_TYPE column reference the non pk column?

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.