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.  [ 4 posts ] 
Author Message
 Post subject: Problem with Many-to-one relationships - Repeated column in
PostPosted: Tue Apr 25, 2006 10:09 am 
Newbie

Joined: Tue Apr 25, 2006 10:02 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="com.ingenix.freya.rulesmanagement.model.RuleSetImpl"
table="FREYA_RULESET"
lazy="false"
>

<id
name="ID"
column="RULESET_IID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
<param name="sequence">S_RULESET</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-RuleSetImpl.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="enterprise"
type="java.lang.Long"
update="true"
insert="true"
column="ENTERPRISE_IID"
/>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="NAME"
/>

<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="TYPE"
/>

<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="DESCRIPTION"
/>

<property
name="effectiveDate"
type="java.util.Date"
update="true"
insert="true"
column="EFFECTIVE_DATE"
/>

<property
name="expiaryDate"
type="java.util.Date"
update="true"
insert="true"
column="EXPIARY_DATE"
/>

<bag
name="rulesetVersions"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
>

<key
>
<column
name="RULESET_IID"
not-null="true"
/>
</key>

<one-to-many
class="com.ingenix.freya.rulesmanagement.model.RulesetVersionImpl"
/>

</bag>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-RuleSetImpl.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
tx = session.beginTransaction();
mLog.debug("Attempting to save: " + object);
result = session.save(object);
tx.commit();

Full stack trace of any exception that occurs:

07:57:33,060 INFO [Configuration] processing association property references
07:57:33,060 INFO [Configuration] processing foreign key constraints
07:57:33,080 ERROR [StandaloneHibernateUtility] Error during initialization of Hibernate SessionFactory from file: apollo_standalone.cfg.xml
org.hibernate.MappingException: Repeated column in mapping for entity: com.ingenix.freya.rulesmanagement.model.RulesetVersionImpl column: RULESET_IID (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:504)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:526)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:544)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:335)
at org.hibernate.mapping.RootClass.validate(RootClass.java:188)
at org.hibernate.cfg.Configuration.validate(Configuration.java:839)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1000)
at com.ingenix.freya.util.hibernate.StandaloneHibernateUtility.init(StandaloneHibernateUtility.java:37)
at com.ingenix.freya.util.hibernate.StandaloneHibernateUtility.getSessionFactory(StandaloneHibernateUtility.java:60)
at com.ingenix.freya.util.hibernate.StandaloneHibernateUtility.getSession(StandaloneHibernateUtility.java:74)
at com.ingenix.freya.util.TestDataGenerator.getCurrentSession(TestDataGenerator.java:154)
at com.ingenix.freya.util.TestDataGenerator.initSubsystem(TestDataGenerator.java:79)
at com.ingenix.freya.util.TestDataGenerator.<init>(TestDataGenerator.java:70)
at com.ingenix.freya.util.HibernateUnitTestBase.setUp(HibernateUnitTestBase.java:51)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Name and version of the database you are using:

SQL Server 2005

The generated SQL (show_sql=true):

No SQL generated yet. Seems to fails while processing associations...

Debug level Hibernate log excerpt:

No app server running.


Top
 Profile  
 
 Post subject: Schema....
PostPosted: Tue Apr 25, 2006 10:54 am 
Newbie

Joined: Tue Apr 25, 2006 10:02 am
Posts: 4
Sorry me. Here is the Schema

CREATE TABLE FREYA_RULESET(
RULESET_IID int IDENTITY(1,1),
ENTERPRISE_IID int NOT NULL,
NAME varchar(100) NOT NULL,
TYPE varchar(10) NOT NULL
CHECK (TYPE IN ('System','Custom')),
DESCRIPTION varchar(255) NOT NULL,
EFFECTIVE_DATE datetime NOT NULL,
EXPIARY_DATE datetime NULL,
CONSTRAINT PK_FREYA_RULESET PRIMARY KEY NONCLUSTERED (RULESET_IID)
)
go

CREATE TABLE FREYA_RULESET_VERSION(
RULESET_VERSION_IID int IDENTITY(1,1),
RULESET_IID int NOT NULL,
ENTERPRISE_IID int NOT NULL,
RULESET_VERSION varchar(10) NOT NULL,
DEPLOYED_TO_TEST varchar(1)
CHECK (DEPLOYED_TO_TEST IN ('Y','N',NULL)),
DEPLOYED_TO_LIVE varchar(1)
CHECK (DEPLOYED_TO_LIVE IN ('Y','N',NULL)),
DATE_OPTION varchar(15),

CONSTRAINT PK_FREYA_RULESET_VERSION PRIMARY KEY NONCLUSTERED (RULESET_VERSION_IID),
constraint FK1_RULESET_VERSION foreign key (RULESET_IID)
references FREYA_RULESET(RULESET_IID)
)
go


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 12:33 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Try this mapping file.


Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class  name="com.ingenix.freya.rulesmanagement.model.RuleSetImpl" table="FREYA_RULESET" lazy="false" >

<id name="ID"
    column="RULESET_IID"
    type="java.lang.Long"
    unsaved-value="null" >
   <generator class="native">
      <param name="sequence">S_RULESET</param>
   </generator>
</id>

<property  name="enterprise"
           type="java.lang.Long"
           update="true"
           insert="true"
           column="ENTERPRISE_IID" />

<property  name="name"
           type="java.lang.String"
           update="true"
           insert="true"
           column="NAME" />

<property name="type"
          type="java.lang.String"
          update="true"
          insert="true"
          column="TYPE" />

<property name="description"
          type="java.lang.String"
          update="true"
          insert="true"
          column="DESCRIPTION" />

<property  name="effectiveDate"
           type="java.util.Date"
           update="true"
           insert="true"
           column="EFFECTIVE_DATE" />

<property name="expiaryDate"
          type="java.util.Date"
          update="true"
          insert="true"
          column="EXPIARY_DATE" />

<bag name="rulesetVersions"
     lazy="false"
     inverse="true"
     cascade="all-delete-orphan" >
  <key >
   <!--<column name="RULESET_IID" not-null="true"/> -->
   <column name="RULESET_IID" not-null="false" insert="false" update="false"/>
  </key>
  <one-to-many class="com.ingenix.freya.rulesmanagement.model.RulesetVersionImpl" />
</bag>

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Thanks and Fixed...
PostPosted: Tue Apr 25, 2006 1:55 pm 
Newbie

Joined: Tue Apr 25, 2006 10:02 am
Posts: 4
I have mapped "RULESET_VERSION_IID" incorrectly and that was the issue. One of my colleague was quick to point out that.

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