-->
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: Cannot specify join table column name for OneToMany Mapping
PostPosted: Wed Jun 20, 2007 11:05 am 
Newbie

Joined: Wed Jun 20, 2007 10:18 am
Posts: 1
Hibernate version:
Using Hibernate 3.2.0 jar and Hibernate Annotations 3.3.0 GA jar.
Using Spring 2.0.2 jar

Mapping documents:
I think most of document is irrelevant. Most relevant part is
...
<prop key="hibernate.hbm2ddl.auto">create</prop>
...

Code between sessionFactory.openSession() and session.close():

Code:
@Entity
@Table(name="SWC_TEMPLATEJOBSCHEDULE")
public class TemplateJobSchedule {
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator = "SWC_TEMPLATEJOBSCHEDULE_SQ")
    @Column(name = "TEMPLATESCHEDULEID")
    private Long templateScheduleId;
   
    ...
   
    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(name="SWC_TEMPLATEJOB_CHILDREN",joinColumns = {@JoinColumn(name="ABCD", referencedColumnName = "TEMPLATESCHEDULEID")})
    private Set<TemplateJobSchedule> tjsSet;
   
}

works fine, producing the create script
Code:
    create table SWC_TEMPLATEJOB_CHILDREN (
        ABCD number(19,0) not null,
        tjsSet_TEMPLATESCHEDULEID number(19,0) not null,
        primary key (ABCD, tjsSet_TEMPLATESCHEDULEID),
        unique (tjsSet_TEMPLATESCHEDULEID)
    )


but,

Code:
    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(name="SWC_TEMPLATEJOB_CHILDREN",joinColumns = {@JoinColumn(name="ABCD", referencedColumnName = "TEMPLATESCHEDULEID")})
    private Set<TemplateJobSchedule> [b]templateJobScheduleSet[/b];

produces the stacktrace below.

Full stack trace of any exception that occurs:

Code:
20 Jun 2007 15:46:56.472 [main] (SchemaExport.java:303) DEBUG org.hibernate.tool.hbm2ddl.SchemaExport  -
    create table SWC_CHAUDHRYS.SWC_TEMPLATEJOB_CHILDREN (
        ABCD number(19,0) not null,
        templateJobScheduleSet_TEMPLATESCHEDULEID number(19,0) not null,
        primary key (ABCD, templateJobScheduleSet_TEMPLATESCHEDULEID),
        unique (templateJobScheduleSet_TEMPLATESCHEDULEID)
    )
20 Jun 2007 15:46:56.503 [main] (NewPooledConnection.java:304) DEBUG com.mchange.v2.c3p0.impl.NewPooledConnection  - com.mchange.v2.c3p0.impl.NewPooledConnection@8ab08f handling a throwable.
java.sql.SQLException: ORA-00972: identifier is too long

   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
   at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
   at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
   at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
   at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1094)
   at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2132)
   at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2015)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2877)
   at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:858)
   at com.mchange.v2.c3p0.impl.NewProxyStatement.executeUpdate(NewProxyStatement.java:64)
   at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:308)
   at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:267)
   at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:190)
   at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
.....


Name and version of the database you are using:

Oracle9i 9.2.0.6.0

The generated SQL (show_sql=true):

Shown above.

Debug level Hibernate log excerpt:

None taken. Cause is known (length of name generated in Hibernate for column)


Would like to be able to specify the name of the column, rather than having tjsSet_TEMPLATESCHEDULEID or templateJobScheduleSet_TEMPLATESCHEDULEID.
Look forward to your assistance on this. Have looked through documentation but have been unsuccessful in finding the appropriate syntax for this.

Thanks for your help.


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.