-->
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: Probleme bei 1:n Beziehung
PostPosted: Wed May 31, 2006 9:34 am 
Newbie

Joined: Wed May 31, 2006 9:19 am
Posts: 2
Hallo,

ich verstehe nicht warum die 1:n Beziehung nicht gemappt wird. Hier mal das Mapping für meine beiden Tabellen:


school

Code:
<hibernate-mapping package="com.businessobjects">
   <class name="SchoolBO" table="HR_SCHOOL"  lazy="true">
   
      <id name="pk" column="ID">
         <generator class="increment" />
      </id>

      <property
            name="startSchool"
            column="START_SCHOOL"
            not-null="true"/>   
            
      <property
            name="endSchool"
            column="END_SCHOOL"
            not-null="true"/>      
            
      <property
            name="day"
            column="DAY"
            type="string"
            not-null="true"
            length="11"/>
            
      <property
            name="startTime"
            column="START_TIME"
            not-null="true"/>
            
      <property
            name="endTime"
            column="END_TIME"
            not-null="true"/>      
      
      <many-to-one
            name="idPersonalDataSheet"
            column="ID_PERSONAL_DATA_SHEET"
            class="com.businessobjects.PersonalDataSheetBO"/>               
         
   </class>   
</hibernate-mapping>


PersonalDataSheet

Code:
<hibernate-mapping package="com.businessobjects">
   <class name="PersonalDataSheetBO" table="HR_PERSONAL_DATA_SHEET">
   
      <id name="pk" column="ID_PERSONAL_DATA_SHEET" unsaved-value="null">
         <generator class="increment"/>
      </id>   
      
      <property
             name="createDate"
             column="CREATE_DATE"
             type="timestamp" />   
                
      <property
            name="givenName"
            column="FIRST_NAME"
            type="string"
            not-null="true"
            length="50"/>
         
       <property
            name="surname"
            column="LAST_NAME"
            type="string"
            not-null="true"
            length="50"/>   
            
      <property
            name="birthday"
            column="BIRTHDAY"
            not-null="true"/>   
                              
      <property
            name="image"
            column="IMAGE"
            not-null="true" />      
            
      <property
            name="fname"
            column="IMAGE_FILE_NAME"
            type="string"
            not-null="true"
            length="255"/>   
            
     <property
            name="mime"
            column="MIME_TYPE"
            type="string"
            not-null="true"
            length="50"/>
            
      <bag name="school"
          lazy="false"
          table="HR_SCHOOL"
          cascade="all-delete-orphan"
          inverse="true" >
         <key column="ID_PERSONAL_DATA_SHEET" />
         <one-to-many class="com.businessobjects.SchoolBO" />
      </bag>
         
   </class>   
</hibernate-mapping>


Und hier noch der Aufruf in meiner Manager Klasse:

Code:
public int createPersonalDataSheetBO(AdminPersonalDataSheetForm apf) throws FileNotFoundException, IOException, DatastoreException {
      
      HibernateUtil.beginTransaction();
      Session s = HibernateUtil.getSession();      
      PersonalDataSheetBO pb = new PersonalDataSheetBO();
            
      //create a timestamp
      Calendar c = Calendar.getInstance();
      long l = c.getTimeInMillis();
      Timestamp ts = new Timestamp(l);
      pb.setCreateDate(ts);
      
      pb.setGivenName(apf.getGivenName());
      pb.setSurname(apf.getSurname());
      pb.setBirthday(apf.getBirthday());
      pb.setImage(apf.getFile().getFileData());
      pb.setFname(apf.getFname());
      pb.setMime(apf.getMime());
      
      //s.save(pb);
      
      SchoolBO sb = null;
      List school = new ArrayList();
      String [] weekArray = apf.getStrArray();
      
      for(int i=0; i < apf.getStrArray().length; i++){
         
         sb = new SchoolBO();
         //sb.setIdPersonalDataSheet(pb.getPk());
         sb.setDay(weekArray[i]);
         sb.setStartSchool(apf.getSchoolStart());
         sb.setEndSchool(apf.getSchoolEnd());
                           
         if(weekArray[i].equals("Montag")){
            sb.setStartTime(apf.getStartMonday());
            sb.setEndTime(apf.getEndMonday());
         }
         if(weekArray[i].equals("Dienstag")){
            sb.setStartTime(apf.getStartTuesday());
            sb.setEndTime(apf.getEndTuesday());
         }
         if(weekArray[i].equals("Mittwoch")){
            sb.setStartTime(apf.getStartWednesday());
            sb.setEndTime(apf.getEndWednesday());
         }
         if(weekArray[i].equals("Donnerstag")){
            sb.setStartTime(apf.getStartThursday());
            sb.setEndTime(apf.getEndThursday());
         }
         if(weekArray[i].equals("Freitag")){
            sb.setStartTime(apf.getStartFrieday());
            sb.setEndTime(apf.getEndFrieday());
         }
         school.add(sb);
         pb.setSchool(school);
      }
      pb.getSchool().retainAll(school);
      pb.getSchool().addAll(school);
      
      s.save(pb);
            
      //s.flush();
      HibernateUtil.commitTransaction();
         
      return pb.getPk();
      
   }


Hoffe mir kann jemand helfen, in der Hibernate Doku habe ich leider auch nicht den Grund gefunden.


Last edited by jimmitenor on Thu Jun 01, 2006 7:46 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 6:43 am 
Newbie

Joined: Wed May 31, 2006 9:31 am
Posts: 9
Location: Südtirol
Welcher Fehler wird geworfen bzw. wo bricht das build-file ab?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 7:39 am 
Newbie

Joined: Wed May 31, 2006 9:19 am
Posts: 2
leniwy wrote:
Welcher Fehler wird geworfen bzw. wo bricht das build-file ab?


Code:
        ... 48 more
Do 01.06.2006 14:21:15:580 ERROR [TP-Processor2] (BasicPropertyAccessor.java:167 Method:get) - IllegalArgumentException in class:
com.businessobjects.PersonalDataSheetBO, getter method of property: pk
Do 01.06.2006 14:21:15:610 ERROR [TP-Processor2] (AbstractFlushingEventListener.java:300 Method:performExecutions) - Could not syn
chronize database state with session
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.businessobjects.Perso
nalDataSheetBO.pk
        at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
        at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
        at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)
        at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)
        at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
        at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:215)
        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
        at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1826)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2172)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at com.gehis.intranet.framework.database.HibernateUtil.commitTransaction(HibernateUtil.java:106)
        at com.gehis.intranet.framework.database.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:45)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at com.gehis.intranet.framework.navigation.NavigationFilter.doFilter(NavigationFilter.java:104)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
        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.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
        ... 40 more





lazy="true" ändert auch nichts.


Top
 Profile  
 
 Post subject: property fehler illegalArgument
PostPosted: Thu Jun 08, 2006 9:47 am 
Newbie

Joined: Sat Sep 24, 2005 10:44 am
Posts: 12
Location: Berlin, Germany
hi

dein fehler liegt beim Type der Variablen pk.

"object is not an instance of declaring class" Du hast wohl einfach ein falschen Type angegeben. Ich vermute mal da steht kein Long bzw. Integer.

martin


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.