-->
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.  [ 13 posts ] 
Author Message
 Post subject: Incomplete insert causes constraint violation (inheritance)
PostPosted: Thu Jul 06, 2006 4:03 am 
Newbie

Joined: Thu Jul 06, 2006 3:06 am
Posts: 6
Hi all :)

I'm having a problem with creating a new object that's defined in an inheritance hierarchy. The basic issue is that when the insert statement is generated for the base class, it's missing two properties that are foreign keys into other tables, causing a constraint violation. The insert statement for the derived class is not generated -- I'm not seeing it on the console, at the very least.

In any case, my object relationships are as follows:
1) A base class, TriviaGame, mapped into users_trivia_games. It references foreign keys in two other tables via the user and triviaGameType properties (also entities);

2) A derived class, SinglePlayerGame, mapped into users_single_player_trivia_games;

3) A User class, mapped into users -- a User has a collection of TriviaGames, and each TriviaGame knows who its User is;

4) A TriviaGameType class, mapped into trivia_game_types -- a TriviaGameType is assigned to each TriviaGame, and a TriviaGameType has a collection of games of its type;

The session factory initializes itself properly, and all other entities in my app work completely. An abridged (extraneous properties removed) version of the TriviaGame hierarchy is below.

Code:
<hibernate-mapping>
    <class name="TriviaGame" table="users_trivia_games" polymorphism="implicit">
        <id name="userTriviaGameId" type="int">
            <column name="user_trivia_game_id" />
            <generator class="native" />
        </id>
        <many-to-one name="user" column="user_id" not-null="true" class="User" insert="false" update="false"/>
        <many-to-one name="triviaGameType" column="trivia_game_type_id" not-null="true" class="TriviaGameType" insert="false" update="false"/>

        <property name="highestScore" type="int" column="highest_score" not-null="true"/>
        <property name="totalQuestions" type="int" column="total_questions" not-null="true"/>
        <property name="datePlayed" type="timestamp" column="date_played" not-null="true"/>
       
        <joined-subclass name="SinglePlayerGame" table="users_single_player_trivia_games">
             <key column="user_trivia_game_id"/>
           <property name="timeElapsed" type="int" column="time_elapsed"/>
        </joined-subclass>
       
    </class>
</hibernate-mapping>


Similarly, the mapping for User and TriviaGameType follow:

Code:
<hibernate-mapping>
    <class name="User" table="users">
        <id name="userId" type="int">
            <column name="user_id" />
            <generator class="native" />
        </id>
   <set name="triviaGames" inverse="true" table="users_trivia_games">
      <key column="user_id" not-null="true" />
      <one-to-many class="TriviaGame" />
   </set>
</hibernate-mapping>

<hibernate-mapping>
    <class name="TriviaGameType" table="trivia_game_type">
        <id name="triviaGameTypeId" type="int">
            <column name="trivia_game_type_id" />
            <generator class="native" />
        </id>
        <set name="triviaGames" table="users_trivia_games">
            <key column="trivia_game_type_id" />
            <one-to-many class="TriviaGame" />
        </set>
    </class>
</hibernate-mapping>



Everything goes fine until I try to save the new game:

Code:
            Session hibernateSession = HibernateSessionFactory.getSession();
            Transaction tx = hibernateSession.beginTransaction();
            User user = (User)hibernateSession.getNamedQuery("userById").setInteger("userId", createGame.getPlayer().getId()).uniqueResult();
            TriviaGameType triviaGameType = (TriviaGameType)hibernateSession.getNamedQuery("singlePlayerGameType").uniqueResult();

            Set<TriviaGame> userTriviaGames = user.getTriviaGames();
            Set<TriviaGame> triviaGameTypeTriviaGames = triviaGameType.getTriviaGames();

            // Create a new TriviaGame entry for the User
            SinglePlayerGame game = new SinglePlayerGame(user, triviaGameType);
            game.setDatePlayed(new Date());
            
            userTriviaGames.add(game);
            triviaGameTypeTriviaGames.add(game);
            
            hibernateSession.save(game);


I see that the following insert statement is created, but nothing more:

Code:
Hibernate: insert into users_trivia_games (highest_score, total_questions, date_played) values (?, ?, ?)


I'm expecting to see "user_id" and "trivia_game_type_id" in the column list as well, as well as an insert into the users_single_player_trivia_games table. The foreign key constraint failure comes, again, from user_id not being provided.

I realize this is a lot of stuff, but I'm really stumped. I'd like to avoid removing the inheritance, and I'm not sure what I'm doing wrong as I have MANY other types mapped and working this exact same way.

Thanks in advance for any help.
C


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 4:25 am 
Newbie

Joined: Thu Jun 01, 2006 5:09 am
Posts: 16
I had the same problem. I'm looking for a better solution, but a workaround is to "extract" ids as properties and setting them by code.
In your case:

add

<property name="userTriviaGameId" type="int" column="user_trivia_game_id" not-null="true"/>

and

<property name="userId" type="int" column="user_id" not-null="true"/>

Remeber to add them to java class and set them in the backbean.

Bye

PS
if i was useful please remeber to rate me


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 11:29 pm 
Newbie

Joined: Thu Jul 06, 2006 3:06 am
Posts: 6
That seems to do the trick!

I don't know why it works, and I'm past caring at this point.

Thanks very much!
C


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 11:59 pm 
Beginner
Beginner

Joined: Tue Jun 28, 2005 2:43 pm
Posts: 29
Location: Silicon Valley
In TriviaGame, you have the <many-to-one> to user mapped as insert="false", update="false". Then in User, you have the set of triviaGames mapped as inverse="true". So nobody ever tries to set the foreign key.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 4:30 am 
Newbie

Joined: Thu Jun 01, 2006 5:09 am
Posts: 16
I tried to set inverse="false" leaving the rest unchanged but it doesn't work.

_________________
Useful posts are life, rating is food


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 4:51 am 
Beginner
Beginner

Joined: Tue Jun 28, 2005 2:43 pm
Posts: 29
Location: Silicon Valley
Could you post your mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 9:19 am 
Newbie

Joined: Thu Jun 01, 2006 5:09 am
Posts: 16
I suppressed unuseful properties:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 10-mag-2006 9.36.53 by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="unibiblio.dati.anagrafica.DAO.Persone" table="persone">
<composite-id name="id" class="unibiblio.dati.anagrafica.DAO.PersoneId">
<key-property name="idUtente" type="int">
<column name="id_utente" />
</key-property>
<key-property name="codbib" type="int">
<column name="codbib" />
</key-property>
</composite-id>
<many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" fetch="select">
<column name="lingua" length="2" />
</many-to-one>
<many-to-one name="dizProfessioni" class="unibiblio.dati.anagrafica.DAO.DizProfessioni" update="false" insert="false" fetch="select">
<column name="lingua" length="2" />
<column name="codprofessione" length="2" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>




<hibernate-mapping>
<class name="unibiblio.dati.anagrafica.DAO.DizProfessioni" table="diz_professioni">
<composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizProfessioniId">
<key-property name="lingua" type="string">
<column name="lingua" length="2" />
</key-property>
<key-property name="codprofessione" type="string">
<column name="codprofessione" length="2" />
</key-property>
</composite-id>
<many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
<column name="lingua" length="2" not-null="true" />
</many-to-one>
<property name="professione" type="string">
<column name="professione" length="50" />
</property>
<set name="persones" inverse="false">
<key>
<column name="lingua" length="2" />
<column name="codprofessione" length="2" not-null="true" />
</key>
<one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
</set>
</class>
</hibernate-mapping>

_________________
Useful posts are life, rating is food


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 10:44 am 
Newbie

Joined: Thu Jul 06, 2006 3:06 am
Posts: 6
Just a quick note to let you guys know that removing the insert="false" and update="false" on any foreign key properties did indeed work for me. Thanks very much frusso.

The only thing that still didn't really make complete sense to me is that I had to include the many-to-one mapping to the user on both the base class and the derived class mapping. That is, there is a many-to-one mapping on both TriviaGame and SinglePlayerTriviaGame. user_id is on the users_single_player_trivia_games table, so I suppose this makes sense -- I just don't see why it wouldn't pick up the mapping from the base class (it's too much to expect it to work that out automatically, I suppose).

I'm now having a different problem with a null or transitive backref error on a class related to the TriviaGame hierarchy, but I think I'll look around a bit first and maybe start a new topic on that one.

Thanks again for all your help, guys.
C


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 10:50 am 
Newbie

Joined: Thu Jul 06, 2006 3:06 am
Posts: 6
By the way, corzar71, I thought that one of the ends of a bidirectional association had to be marked as inverse -- specifically, the many-sided end -- to prevent the same entity from being inserted twice.

Is this just me reading the mapping docs incorrectly again?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 12:40 pm 
Beginner
Beginner

Joined: Tue Jun 28, 2005 2:43 pm
Posts: 29
Location: Silicon Valley
From the docs, section 6.2.5:
Very important note: If the foreign key column of a <one-to-many> association is declared NOT NULL, you must declare the <key> mapping not-null="true" or use a bidirectional association with the collection mapping marked inverse="true". See the discussion of bidirectional associations later in this chapter.

And then in section 7.4.1:
It is important that you define not-null="true" on the <key> element of the collection mapping if the underlying foreign key column is NOT NULL. Don't only declare not-null="true" on a possible nested <column> element, but on the <key> element.

The mapping of the set DizProfessioni.persones declares the nested codprofessione column as not-null, but not the <key> itself. That may be the problem.

The other alternative is to declare the set as inverse="true", but remove update="false" insert="false" on the many-to-one side. For lists you need to let Hibernate manage the association from the collection side so it can maintain the index column, but for sets it should work fine to manage the association from the many-to-one side.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 12, 2006 6:19 am 
Newbie

Joined: Thu Jun 01, 2006 5:09 am
Posts: 16
I tried with not null="true" also in key property and it doesn't work.
I deleted <<insert="false" update="false">> but when stating it gave me this exception:



2:17:00,734 ERROR [STDERR] org.hibernate.MappingException: Repeated column in mapping for entity: unibiblio.dati.anagrafica.DAO.Persone column: lingua (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:597)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:615)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:988)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1173)
at org.jboss.seam.core.Hibernate.startup(Hibernate.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
at org.jboss.seam.Component.callComponentMethod(Component.java:1119)
at org.jboss.seam.Component.callCreateMethod(Component.java:1107)
at org.jboss.seam.Component.newInstance(Component.java:1096)
at org.jboss.seam.Component.getInstance(Component.java:1044)
at org.jboss.seam.Component.getInstance(Component.java:1027)
at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:88)
at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:68)
at org.jboss.seam.init.Initialization.init(Initialization.java:94)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:30)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297)
at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
at $Proxy29.start(Unknown Source)
at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.ws.server.WebServiceDeployer.start(WebServiceDeployer.java:117)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
at $Proxy30.start(Unknown Source)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanPro
12:17:00,734 ERROR [STDERR] xyExt.java:190)
at $Proxy8.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:334)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:504)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:207)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:218)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:197)

_________________
Useful posts are life, rating is food


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 12, 2006 1:32 pm 
Beginner
Beginner

Joined: Tue Jun 28, 2005 2:43 pm
Posts: 29
Location: Silicon Valley
Yes, I just noticed in your mapping that Persone.dizLingue uses the lingua column as a foreign key to DizLingue, then again as one component of the composite foreign key to DizProfessioni. Assuming this is intentional, you do need to make sure that only one of these is actually maintaining the content of the lingua column. Basically, as many properties as you want can 'read' the contents of this column (via insert="false" update="false", or by using formula instead of column in the declaration), but only one can 'write' the column. In this case, my best guess is that you want Persone.dizProfessioni to be where things get set (i.e. insert="true" update="true"), and Persone.dizLingue to be read-only (insert="false" update="false").


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 3:35 am 
Newbie

Joined: Thu Jun 01, 2006 5:09 am
Posts: 16
Yes, I thought that but I have another mapping (I didn't post it) that uses lingua as id, so I'll have the same problem. Below there's the complete mapping I use. Let's try to understand if there's a way to resolve it else I'll open a bug ticket to the hibernate developers space.


<hibernate-mapping>
<class name="unibiblio.dati.anagrafica.DAO.Persone" table="persone">
<composite-id name="id" class="unibiblio.dati.anagrafica.DAO.PersoneId">
<key-property name="idUtente" type="java.lang.Integer">
<column name="id_utente" />
</key-property>
<key-property name="codbib" type="java.lang.Integer">
<column name="codbib" />
</key-property>
</composite-id>
<many-to-one name="dizNazioni" class="unibiblio.dati.anagrafica.DAO.DizNazioni" fetch="select">
<column name="siglanazione" length="2" not-null="true" />
</many-to-one>
<many-to-one name="dizTitolidistudio" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" update="false" insert="false" fetch="select">
<column name="lingua" length="2" />
<column name="codice_titolostudio" length="1" />
</many-to-one>
<many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" fetch="select">
<column name="lingua" length="2" />
</many-to-one>
<many-to-one name="anagbiblio" class="unibiblio.dati.anagrafica.DAO.Anagbiblio" update="false" insert="false" fetch="select">
<column name="codbib" not-null="true" />
</many-to-one>
<many-to-one name="persone" class="unibiblio.dati.anagrafica.DAO.Persone" fetch="select">
<column name="id_padre" />
<column name="codbib_padre" />
</many-to-one>
<many-to-one name="dizProfessioni" class="unibiblio.dati.anagrafica.DAO.DizProfessioni" update="false" insert="false" fetch="select">
<column name="lingua" length="2" />
<column name="codprofessione" length="2" not-null="true" />
</many-to-one>
<many-to-one name="dizCategorieutenti" class="unibiblio.dati.anagrafica.DAO.DizCategorieutenti" fetch="select">
<column name="tip_ute" length="1" not-null="true" />
</many-to-one>
<many-to-one name="dizProvincie" class="unibiblio.dati.anagrafica.DAO.DizProvincie" fetch="select">
<column name="siglaprovincia" length="2" />
</many-to-one>
<property name="userName" type="string">
<column name="user_name" length="30" />
</property>
<property name="password" type="string">
<column name="password" length="30" />
</property>
.
.
.
.
.
.
</class>
</hibernate-mapping>



<hibernate-mapping>
<class name="unibiblio.dati.anagrafica.DAO.DizProfessioni" table="diz_professioni">
<composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizProfessioniId">
<key-property name="lingua" type="string">
<column name="lingua" length="2" />
</key-property>
<key-property name="codprofessione" type="string">
<column name="codprofessione" length="2" />
</key-property>
</composite-id>
<many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
<column name="lingua" length="2" not-null="true" />
</many-to-one>
<property name="professione" type="string">
<column name="professione" length="50" />
</property>
<set name="persones" inverse="true">
<key>
<column name="lingua" length="2" />
<column name="codprofessione" length="2" not-null="true" />
</key>
<one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
</set>
</class>
</hibernate-mapping>


<hibernate-mapping>
<class name="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" table="diz_titolidistudio">
<composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudioId">
<key-property name="lingua" type="string">
<column name="lingua" length="2" />
</key-property>
<key-property name="codiceTitolostudio" type="string">
<column name="codice_titolostudio" length="1" />
</key-property>
</composite-id>
<many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
<column name="lingua" length="2" not-null="true" />
</many-to-one>
<property name="titolo" type="string">
<column name="titolo" length="50" not-null="true" />
</property>
<set name="persones" inverse="true">
<key>
<column name="lingua" length="2" />
<column name="codice_titolostudio" length="1" />
</key>
<one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
</set>
</class>
</hibernate-mapping>

_________________
Useful posts are life, rating is food


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.