-->
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.  [ 9 posts ] 
Author Message
 Post subject: Bizarre session.load??????????
PostPosted: Thu Aug 18, 2005 6:27 am 
Beginner
Beginner

Joined: Fri May 13, 2005 9:39 am
Posts: 21
Hi,
I've got a strange behaviour with session.load.
The part of my database that raise this comportement is the following one:
Project_Charter references thru Project_Id Project_Activity
Each entry in Project_Activity has at least one element in Poject_Charter.
The Table project_Charter is the table in which important data of projects are stored (name, objectives, aso)
In my table Project_Activity, I have the project 242. when I want to insert a new version of the project charter (after user modification of project name, aso), I reload my project (using an Ineger stored in httpsession) and I create a new instance of Project_Charter.
When I save the newly created project charter, Hibernate raise the error:
null is not a valid identifier.

I've inspected my object ProjectActivity after the load:
Code:
ProjectActivity p = session.load(ProjectActivity.class, integer242);

and all fields (including the key attribute) are null.
when I called a getter of a property, the result is not null.
Considering the fact that all the property of my class are public, I have the following behavior:
Code:
Session session = HBSF.currentSession();
ProjectActivity p = (ProjectActivity)session.load(ProjectActivity.class, new Integer(242));
System.out.println(p.projectId);
//return on the console: null
System.out.println(p.getProjectId());
//return on the console: 242
session.close();

When I invoke a getter, it doesn't modify the value of the associated property, it doesn't work like a lazy initialization.

Can you see a reason?
Don't you think it's bizarre?

If you have some help or you need more information...

XOrangoutan


Hibernate version:2

Mapping documents:
PROJECT_ACTIVITY --> ProjectActivity:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Wed Apr 06 16:18:35 CEST 2005                         -->
<hibernate-mapping package="com.isover.isolineproject.model">

   <class name="ProjectActivity" table="PROJECT_ACTIVITY" proxy="ProjectActivity">
      <id name="projectId" column="PROJECT_ID"
         type="java.lang.Integer">
         <generator class="increment" />
      </id>

      <property name="businessC" column="BUSINESS_C"
         type="java.lang.String" />
      <property name="projectCode" column="PROJECT_CODE"
         type="java.lang.String" />
      <property name="isolineDocObjId" column="ISOLINE_DOC_OBJ_ID"
         type="java.lang.Integer" />
      <property name="projectSiriusId" column="PROJECT_SIRIUS_ID"
         type="java.lang.Integer" />

      <many-to-one name="parentProjectActivity"
         column="PARENT_PROJECT_ID" class="ProjectActivity" />
      <many-to-one name="originProjectActivity"
         column="PROJECT_ORIGIN_ID" class="ProjectActivity" />
      <many-to-one name="projectActivityType" column="PROJECT_TYPE_ID"
         class="ProjectActivityType" not-null="true" />

      <set name="activityMembers" table="PROJECT_ACTIVITY_MEMBERS"
         lazy="true" inverse="false" cascade="all">
         <key column="PROJECT_ID" />
         <many-to-many
            class="com.isover.isolineproject.model.Person"
            column="PERSON_ID" />
      </set>

      <set name="projectCharacteristics" table="PROJECT_CHARACTERISTICS"  inverse="false" lazy="true">
         <key column="PROJECT_ID" />
         <many-to-many
            class="com.isover.isolineproject.model.Characteristics"
            column="CHARACTERISTIC_ID" />
      </set>

      <set name="projectCharters" order-by="LAST_UPDATE" inverse="true"  lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="ProjectCharter"  />
      </set>
      
      <set name="subProjectActivity" inverse="false" lazy="true">
         <key column="PARENT_PROJECT_ID" />
         <one-to-many class="ProjectActivity" />
      </set>
      
      <set name="projectGateKeepers" order-by="GATE_NUMBER" inverse="false"  lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="ProjectGateKeepers"  />
      </set>

      <set name="yearlyAchievmentsAndPrograms" order-by="YEAR" inverse="false" lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="YearlyAchievmentAndProgram" />
      </set>

      <set name="stages" order-by="STAGE_ID" inverse="false"  lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="Stage" />
      </set>
      
      <set name="GIE" inverse="false" lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="Gie" />
      </set>
      
      <set name="TollGates" inverse="true" lazy="true" order-by="PHASE_ID">
         <key column="PROJECT_ID"/>
         <one-to-many class="TollGate"/>
      </set>
      
   </class>
   <sql-query name="active.project">
      <return alias="pa" class="ProjectActivity"/>   
      Select {pa.*} from Project_Activity {pa}, Project_Status ps
      where pa.project_id = ps.project_id
      and last_update = (select max(last_update) from Project_Status where pa.project_id = project_id)
      order by pa.project_Code      
   </sql-query>
</hibernate-mapping>


PROJECT_CHARTER --> ProjectCharter:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Wed Apr 06 16:12:30 CEST 2005                         -->
<hibernate-mapping package="com.isover.isolineproject.model">

    <class name="ProjectCharter" table="PROJECT_CHARTER">
        <composite-id name="id" class="ProjectCharterKey">
            <key-property name="lastUpdate" column="LAST_UPDATE" type="timestamp"/>
            <key-many-to-one name="projectActivity" column="PROJECT_ID" class="ProjectActivity"/>
        </composite-id>

        <property name="projectName" column="PROJECT_NAME" type="java.lang.String" />
        <property name="projectMainObjectives" column="PROJECT_MAIN_OBJECTIVES" type="text"  not-null="true" />
      <property name="ideationDate" column="IDEATION_DATE" type="date" />
      <property name="postLaunchDate" column="POST_LAUNCH_DATE" type="date" />
      
        <many-to-one name="projectActivityPriority" column="PROJECT_ACTIVITY_PRIORITY_ID" class="ProjectActivityPriority" />
        <many-to-one name="projectLevel" column="LEVEL_ID" class="ProjectLevel" />
       
        <set name="detailedObjectives" lazy="true" inverse="true" order-by="objective_rank">
           <key>
              <column name="LAST_UPDATE"/>           
              <column name="PROJECT_ID"/>
           </key>
           <one-to-many class="ProjectDetailedObjectives"/>
        </set>
    </class>
   
</hibernate-mapping>


Full stack trace of any exception that occurs:
Code:
java.lang.NullPointerException: null is not a valid identifier
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1928)
at com.isover.isolineproject.persistence.managers.ProjectLevelManager.findbyLevelId(ProjectLevelManager.java:33)
at com.isover.isolineproject.projectoverview.struts.forms.ProjectCharterMainForm.getProjectLevel(ProjectCharterMainForm.java:267)
at com.isover.isolineproject.persistence.managers.ProjectCharterManager.createNewVersion(ProjectCharterManager.java:118)
at com.isover.isolineproject.projectoverview.struts.action.EditProjectCharterAction.update(EditProjectCharterAction.java:410)
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:324)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.isover.isolineproject.HibernateFilter.doFilter(HibernateFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

Name and version of the database you are using:Oracle 9i

The generated SQL (show_sql=true):


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 7:13 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:15 am
Posts: 24
From what I can tell, this is normal Hibernate functionality.

When you perform session.load() you will get back a proxy object, and if you are looking at the SQL in the log, you'll notice nothing has been executed yet.
As soon as you call the accessor method on the first non-id field (the id is available as you performed load with it as a parameter), then the SQL is performed and the fields populated.

To ensure no confusion, always use accessor/mutator methods.


Hope this helps.


Top
 Profile  
 
 Post subject: something I don't understand
PostPosted: Thu Aug 18, 2005 7:43 am 
Beginner
Beginner

Joined: Fri May 13, 2005 9:39 am
Posts: 21
Thank you for you reply, but there's something I don't understand.
The load method return an instance with all non lazy fields set to the value in the database.
In my example, even the identifier field (projectId) is not set (value=null), but I get a value when I called the appropriate getter (getProjectId()).

I also have a question, what is accessor/mutator method?


Top
 Profile  
 
 Post subject: EUREKA
PostPosted: Thu Aug 18, 2005 7:58 am 
Beginner
Beginner

Joined: Fri May 13, 2005 9:39 am
Posts: 21
The mapping of my table PROJECT_ACTIVITY was declared as lazy. As a consequence, the class ProjectActivity was used as a proxy class (it means that fields are not initialized by the session.load but the getter methods return the right value)

Thank a lot to CSwinney to enlight my problems.


Merci beaucoup


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 8:29 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:15 am
Posts: 24
The accessor/mutator methods are simply your getters and setters respectively.

Hope this helps.


Top
 Profile  
 
 Post subject: Proxy!!!!!!!!!
PostPosted: Thu Aug 18, 2005 9:51 am 
Beginner
Beginner

Joined: Fri May 13, 2005 9:39 am
Posts: 21
So, now, I know that because I use a proxy, fields in my instance are null.
But I use this proxy object in a composite identifier, and when I call session.save(myBrandNewProjectCharter); I ve got an error (identifier can't be null.

Question: How can I save my object (see code below)?

Thank you


Description of my application:
This application is a Project Management Application.
Project are stored in a table PROJECT_ACTIVITY. In this table there is the identifier (PROJECT_ID Number), the code in our Organization (PROJECT_CODE VARCHAR2), the Id of the project space in livelink (EDM). Informations in PROJECT_ACTIVITY are quite invariant.
the Name of the Project, main objectives, ... are stored in PROJECT_CHARTER table. The primary key of PROJECT_CHARTER is composed with a timestamp (to keep versions) and the PROJECT_ID (Foreign key on PROJECT_ACTIVITY)

Mapping of PROJECT_ACTIVITY:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Wed Apr 06 16:18:35 CEST 2005                         -->
<hibernate-mapping package="com.isover.isolineproject.model">

   <class name="ProjectActivity" table="PROJECT_ACTIVITY" proxy="ProjectActivity" lazy="true">
      <id name="projectId" column="PROJECT_ID"
         type="java.lang.Integer">
         <generator class="increment" />
      </id>

      <property name="businessC" column="BUSINESS_C"
         type="java.lang.String" />
      <property name="projectCode" column="PROJECT_CODE"
         type="java.lang.String" />
      <property name="isolineDocObjId" column="ISOLINE_DOC_OBJ_ID"
         type="java.lang.Integer" />
      <property name="projectSiriusId" column="PROJECT_SIRIUS_ID"
         type="java.lang.Integer" />

      <many-to-one name="parentProjectActivity"
         column="PARENT_PROJECT_ID" class="ProjectActivity" />
      <many-to-one name="originProjectActivity"
         column="PROJECT_ORIGIN_ID" class="ProjectActivity" />
      <many-to-one name="projectActivityType" column="PROJECT_TYPE_ID"
         class="ProjectActivityType" not-null="true" />

      <set name="activityMembers" table="PROJECT_ACTIVITY_MEMBERS"
         lazy="true" inverse="false" cascade="all">
         <key column="PROJECT_ID" />
         <many-to-many
            class="com.isover.isolineproject.model.Person"
            column="PERSON_ID" />
      </set>

      <set name="projectCharacteristics" table="PROJECT_CHARACTERISTICS"  inverse="false" lazy="true">
         <key column="PROJECT_ID" />
         <many-to-many
            class="com.isover.isolineproject.model.Characteristics"
            column="CHARACTERISTIC_ID" />
      </set>

      <set name="projectCharters" order-by="LAST_UPDATE" inverse="true"  lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="ProjectCharter"  />
      </set>
      
      <set name="subProjectActivity" inverse="false" lazy="true">
         <key column="PARENT_PROJECT_ID" />
         <one-to-many class="ProjectActivity" />
      </set>
      
      <set name="projectGateKeepers" order-by="GATE_NUMBER" inverse="false"  lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="ProjectGateKeepers"  />
      </set>

      <set name="yearlyAchievmentsAndPrograms" order-by="YEAR" inverse="false" lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="YearlyAchievmentAndProgram" />
      </set>

      <set name="stages" order-by="STAGE_ID" inverse="false"  lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="Stage" />
      </set>
      
      <set name="GIE" inverse="false" lazy="true">
         <key column="PROJECT_ID" />
         <one-to-many class="Gie" />
      </set>
      
      <set name="TollGates" inverse="true" lazy="true" order-by="PHASE_ID">
         <key column="PROJECT_ID"/>
         <one-to-many class="TollGate"/>
      </set>
      
   </class>
   <sql-query name="active.project">
      <return alias="pa" class="ProjectActivity"/>   
      Select {pa.*} from Project_Activity {pa}, Project_Status ps
      where pa.project_id = ps.project_id
      and last_update = (select max(last_update) from Project_Status where pa.project_id = project_id)
      order by pa.project_Code      
   </sql-query>
</hibernate-mapping>


Mapping of PROJECT_CHARTER:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Wed Apr 06 16:12:30 CEST 2005                         -->
<hibernate-mapping package="com.isover.isolineproject.model">

    <class name="ProjectCharter" table="PROJECT_CHARTER">
        <composite-id name="id" class="ProjectCharterKey">
            <key-property name="lastUpdate" column="LAST_UPDATE" type="timestamp"/>
            <key-many-to-one name="projectActivity" column="PROJECT_ID" class="ProjectActivity"/>
        </composite-id>

        <property name="projectName" column="PROJECT_NAME" type="java.lang.String" />
        <property name="projectMainObjectives" column="PROJECT_MAIN_OBJECTIVES" type="text"  not-null="true" />
      <property name="ideationDate" column="IDEATION_DATE" type="date" />
      <property name="postLaunchDate" column="POST_LAUNCH_DATE" type="date" />
      
        <many-to-one name="projectActivityPriority" column="PROJECT_ACTIVITY_PRIORITY_ID" class="ProjectActivityPriority" />
        <many-to-one name="projectLevel" column="LEVEL_ID" class="ProjectLevel" />
       
        <set name="detailedObjectives" lazy="true" inverse="true" order-by="objective_rank">
           <key>
              <column name="LAST_UPDATE"/>           
              <column name="PROJECT_ID"/>
           </key>
           <one-to-many class="ProjectDetailedObjectives"/>
        </set>
    </class>
   
</hibernate-mapping>


When the user modify project main objectives, I create a new version of the charter stamped with current date.

Code in which I get the error:
Code:
      Date currentDate = GregorianCalendar.getInstance().getTime();
      String currentYear = Integer.toString(GregorianCalendar.getInstance().get(GregorianCalendar.YEAR));
      
      StrategyItemsManager siManager = new StrategyItemsManager();
      YearlyStrategyManager yManager = new YearlyStrategyManager();
      CharacteristicManager cManager = new CharacteristicManager();
      PersonManager pManager = new PersonManager();      
      ProjectActivityManager paManager = new ProjectActivityManager();
      
      Transaction tx = null;
      try {
          Session session = HibernateSessionFactory.currentSession();
          tx = session.beginTransaction();
[color=red]//Here I get my project from the database with a session.load[/color]
          ProjectActivity project = paManager.findByProjectActivityId( pcForm.getProjectId() );
[color=red]//Here I've tried to use Hibernate.initialize(project); without success.[/color]

          ProjectCharter basedOn = project.getProjectCharterVersion( new Date(pcForm.getVersion().longValue()) );
         
          if (basedOn == null)
            throw new IsoException(this.getClass().getName(),"ProjectCharterManager - createNewVersion", new Exception("Could not update a Project Charter based on null Project Charter"));
   
          // 1°Section : Project Charter
          ProjectCharterMainForm mainForm = pcForm.getMainForm();
         
          ProjectCharterKey newcharterId = new ProjectCharterKey();
          newcharterId.setLastUpdate(currentDate);
          newcharterId.setProjectActivity(basedOn.getId().getProjectActivity());
          ProjectCharter newCharter = new ProjectCharter( newcharterId );
          newCharter.setProjectName( mainForm.getProjectName() );
          newCharter.setProjectMainObjectives( mainForm.getObjectivesSummary() );
          newCharter.setProjectActivityPriority( mainForm.getPriority() );
          Person currentPrjLeader = project.getProjectLeader();
          Person newPrjLeader = mainForm.getProjectLeader();
          if (!currentPrjLeader.equals(newPrjLeader)) {
             project.defineNewProjectLeader(newPrjLeader);
          }
               
          if (project.isActivity()) {
             newCharter.setProjectLevel(null);
             newCharter.setIdeationDate(null);
             newCharter.setPostLaunchDate(null);
          } else {
             newCharter.setProjectLevel( mainForm.getProjectLevel() );
                  
             DateFormat dF = DateFormatUtil.getDateFormat();
             try { // Exception is never catch, Struts Form validate have already check it
                if (mainForm.getIdeationDate()==null || mainForm.getIdeationDate().length()==0)
                   newCharter.setIdeationDate(null);
                else
                   newCharter.setIdeationDate( dF.parse(mainForm.getIdeationDate()) );
                
                if (mainForm.getPostLaunchDate() == null || mainForm.getPostLaunchDate().length()==0)
                   newCharter.setPostLaunchDate(null);
                else
                   newCharter.setPostLaunchDate( dF.parse(mainForm.getPostLaunchDate()) );
             } catch (ParseException pe) { }
          }
         
          if ( !project.getPortfolio().getPortfolioId().equals(mainForm.getPortfolioID()) ) {
             System.out.println("in a new portfolio");
               ProjectPortfolioKey pPortfolioKey = new ProjectPortfolioKey();
               pPortfolioKey.setPortfolio( mainForm.getPortfolio() );
               pPortfolioKey.setProjectActivity( project );
               pPortfolioKey.setLastUpdate( currentDate );
               ProjectPortfolio pPortfolio = new ProjectPortfolio(pPortfolioKey);
               session.save(pPortfolio);             
          }
            
          session.save(newCharter);         
            
            
          // 2° Section : Strategic Fit
          newCharter.setDetailedObjectives(new HashSet());
          StrategicFitForm sForm = pcForm.getStrategicFitForm();
          Integer[] strategyItemIds = sForm.getStrategyItems();
          for (int i=0; i< strategyItemIds.length; i++) {
            Integer strategyItemId  = strategyItemIds[i];
            YearlyStrategy y =  (YearlyStrategy)yManager.findById(YearlyStrategy.class, new YearlyStrategyKey( siManager.findById(strategyItemId), currentYear) );
                  
            ProjectStrategyKey key = new ProjectStrategyKey();
            key.setYearlyStrategy(y);
            ProjectStrategy strategy = new ProjectStrategy(key);
            newCharter.addYearlyStrategy(strategy);
            session.save(strategy);
         }
         session.update(newCharter);
         
            
         // 3° Detailed Objectives
         DetailedObjectivesForm dForm = pcForm.getObjectivesForm();
         int rank = 1;
         ObjectiveData[] objectivesList = dForm.getObjectives();
         for (int i=0; i < objectivesList.length; i++) {
            ObjectiveData objectives = objectivesList[i];
            ProjectDetailedObjectivesKey pdKey = new ProjectDetailedObjectivesKey();
            pdKey.setObjectiveRank(objectives.getRank());
            pdKey.setProjectCharter(newCharter);
            ProjectDetailedObjectives pdo = new ProjectDetailedObjectives(pdKey);
            pdo.setObjectiveDescription( objectives.getObjective() );
            rank++;
            
            session.save(pdo);
            newCharter.getDetailedObjectives().add(pdo);
         }
         session.update(newCharter);
   
         session.flush();
         tx.commit();   
         session.refresh(project);
      } catch (HibernateException he) {
         try {
            if (tx != null) tx.rollback();
         } catch (HibernateException he2) { System.out.println(he2); }
         he.printStackTrace();
         throw new IsoException(this.getClass().getName(),"ProjectCharterManager - createNewVersion", he);
      }
   }   



Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 10:42 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:15 am
Posts: 24
Off the top of my head that /should/ work.

Could you post the exerpt from your Hibernate log which shows the exception, there's a good chance I may not have an answer as I've not had the chance to use composite keys yet in any Hibernate system.


Top
 Profile  
 
 Post subject: Sorry and thank you
PostPosted: Thu Aug 18, 2005 10:47 am 
Beginner
Beginner

Joined: Fri May 13, 2005 9:39 am
Posts: 21
I've found the solution.
It is not linked to Proxies, one of my colleagues have added a functionnality without testing it on a specific type of project.
We've 3 types of projects (Project, Activity (long term project) and Plant support project). The type Plant support Project have the behaviour of an activity and it was not treated like an activity. so the system raised an error on somethog else.

Sorry for the time you spent, but thank you a lot for the help you give.

I've learned a lot of things thru our exchange.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 10:54 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:15 am
Posts: 24
No worries, glad to know it's all working now.


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