-->
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: problem of comprehension relation many-to-many
PostPosted: Fri Jun 24, 2005 4:41 am 
Newbie

Joined: Wed Jun 22, 2005 5:11 am
Posts: 3
Hello,
I do not manage to fill out my table associated with 2 classes in relation many-to-many. Here are what I do but I perhaps understood of through
Agent.hbm



Code:
  <hibernate-mapping>
   
  <class name="com.minosis.hibernate.Agent" table="AGENT">
   
  <id name="uid" type="string" unsaved-value="any" >
  <column name="uid" sql-type="varchar(30)" not-null="true"/>
  <generator class="assigned" />
  </id>
   
  [....]diffĂ©rents <porperty>
   
  <set name="habilitation" table="agent_hab" lazy="false">
   <key>
    <column name="uid_agent" sql-type="varchar(30)" not-null="true"/>
   </key>
   <many-to-many class="com.minosis.hibernate.Habilitations" >
    <column name="hab_id" not-null="true"/>
   </many-to-many>
  </set>
   
  </class>
   
  <class name="com.minosis.hibernate.Habilitations" table="habilitation">
   <id name="id" column="id" type="integer" unsaved-value="any" >
    <generator class="increment">
     <param name="increment">habilitation_id_seq</param>
    </generator>
   </id>
         <property name="nom" type="string">
           <column name="nom" sql-type="varchar(30)" not-null="true"/>
         </property>
         <property name="parametre" type="string">
     <column name="parametre" sql-type="varchar(255)" />
       </property>
   <set name="AGENT" table="agent_hab" inverse="true" lazy="false">
    <key>
      <column name="hab_id" not-null="true"/>
     </key>
    <many-to-many class="com.minosis.hibernate.Agent" >
      <column name="uid_agent" sql-type="varchar(30)" not-null="true"/>
     </many-to-many>
   </set>
  </class>
   
  </hibernate-mapping>




And then in my code I make for each agent


Code:
   Session session = HibernateUtil.currentSession();
   Transaction tx = session.beginTransaction();

[...]

    agent.setUid(ag.getUid());
    [...]
    agent.setHabilitation(setHab);   
    session.saveOrUpdate(agent);




then for each enabling: (= habilitation in french)


Code:
    habilitation.setNom(hab.getNomservice());
    habilitation.setParametre(hab.getPorts());
    habilitation.setAGENT(setAgent);
    session.saveOrUpdate(habilitation);

[...]

   tx.commit();
   HibernateUtil.closeSession();




I precise that the tables Agents and enabling are correctly filled. the Set are apparently exact(j' could not verifier for everyone ) but I have an error like that


Code:
Hibernate: insert into agent_hab (uid_agent, hab_id) values (?, ?)
22 juin 2005 11:02:41 net.sf.hibernate.impl.SessionImpl execute
GRAVE: Could not synchronize database state with session
net.sf.hibernate.MappingException: No persister for: SQLServer.habilitation
  at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
  at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
  at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
  at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2759)
  at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
  at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:47)
  at net.sf.hibernate.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:384)
  at net.sf.hibernate.collection.Set.writeTo(Set.java:226)
  at net.sf.hibernate.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:523)
  at net.sf.hibernate.impl.ScheduledCollectionRecreate.execute(ScheduledCollectionRecreate.java:23)
  at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
  at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2375)
  at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
  at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)



Do I have make an error of comprehension or then my problem comes besides???



Thanks


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.