-->
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: many-to-many join on none primary key field
PostPosted: Wed Apr 12, 2006 12:07 pm 
Newbie

Joined: Fri Jul 15, 2005 10:02 am
Posts: 12
Trying to do a many-to-many (w/ join table) on a field in a table that is not the primary key (but is unique). I "think" hibernate is trying to map the GUID (40 length character) to the NUMBER(10) id in the STATIC_HTMLS table. But I am not sure. Any ideas? Anyone?

I am getting the following error

Code:
org.hibernate.exception.SQLGrammarException: could not initialize a collection

SQL Error: 1722, SQLState: 42000
ORA-01722: invalid number


The ORA number means that oracle tried to perform a numeric operation on a non-numeric field.

Mapping:
Code:
<class name="StaticHtml" table="STATIC_HTMLS">
  <id name="id" column="STATIC_HTML_ID">
    <generator class="native"/>
  </id>

  <property name="guid" column="GUID" unique="true" />

  <set name="permissionSet" table="PERMISSION_X_GUID">
    <key column="GUID"/>
      <many-to-many class="Permission" column="PERMISSION_ID" unique="true"/>
  </set>
</class>

<class name="Permission" table="PERMISSIONS">
  <id name="id" column="PERMISSION_ID">
    <generator class="native"/>
  </id>
  <property name="plevel" column="PLEVEL" />
</class>


SQL DDL
Code:
CREATE TABLE PERMISSIONS
(
PERMISSION_ID   NUMBER(10)      NOT NULL,
PLEVEL          NUMBER(10)      NOT NULL,
PRIMARY KEY(PERMISSION_ID)
);

CREATE TABLE PERMISSION_X_GUID
(
PERMISSION_ID   NUMBER(10)      NOT NULL,
GUID          CHAR(40)      NOT NULL,
PRIMARY KEY(PERMISSION_ID,GUID)
);

CREATE TABLE STATIC_HTMLS
(
STATIC_HTML_ID    NUMBER(10)      NOT NULL,
GUID          CHAR(40)      NOT NULL,
PRIMARY KEY(STATIC_HTML_ID)
);


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.