-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with @SecondaryTable annotations
PostPosted: Fri Sep 12, 2008 11:13 am 
Newbie

Joined: Fri Sep 12, 2008 11:02 am
Posts: 2
I am using 3.2.6.ga - also tried 3.3.1.ga and Annotations version 3.4.0.CR2 - also tried 3.4.0.GA.

I have a relatively simple mapping I'm trying to write using a secondary table. The model object is fine before I add the secondary table columns, but once I add them it dies.

e.g.
Code:
@Entity
@Table(name = "CUSTOMER_SERVICE")
@SecondaryTable(name = "PORT_STATUS",
        pkJoinColumns = {@PrimaryKeyJoinColumn(name="PORT_ID", referencedColumnName="PORT_ID")} )
public class CustomerService extends ModelObject {

    ... normal columns working fine ...

    @Column(table = "PORT_STATUS", name = "PORT_OPERATIONAL")
    public boolean isOperational() {
        return operational;
    }

    public void setOperational(boolean operational) {
        this.operational = operational;
    }
}


I get the following exception:
Caused by: org.hibernate.AnnotationException: Cannot find the expected secondary table: no PORT_STATUS available for <snip packages>.CustomerService
at org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:293)

This occurs on startup - i.e. before it has even touched the DB. Any ideas?


Top
 Profile  
 
 Post subject: Re: Problem with @SecondaryTable annotations
PostPosted: Fri Sep 12, 2008 11:51 am 
Newbie

Joined: Fri Sep 12, 2008 11:02 am
Posts: 2
Well, I found the problem by looking at the source. Basically the table name specified in the @SecondaryTable annotation gets stored in lower case. When it comes to look up the table from the @Column annotation it can't find the (uppercase) table name. The lookup is in the Ejb3Column class, I'm not sure where you should be converting to lowercase.

So I can specify the column as:
Code:
    @Column(table = "port_status", name = "PORT_OPERATIONAL")
    public int isOperational() {
        return operational;
    }


and it works.


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.