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):