Code:
Hibernate: select bugactiv0_.bug_id as bug_id, bugactiv0_.bug_when as bug_when, bugactiv0_.fieldId as fieldId, bugactiv0_.who as who, bugactiv0_.added as added, bugactiv0_.attach_id as attach_id, bugactiv0_.removed as removed from bugs_activity bugactiv0_
java.lang.NullPointerException
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 net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:170)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1961)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.find(Loader.java:620)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314)
at net.sf.jagzilla.hibernate.BugActivityTest.testList(BugActivityTest.java:48)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:395)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:279)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:171)
rethrown as net.sf.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of net.sf.jagzilla.hibernate.BugActivity.attachId
at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:49)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:170)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1961)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.find(Loader.java:620)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314)
at net.sf.jagzilla.hibernate.BugActivityTest.testList(BugActivityTest.java:48)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:395)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:279)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:171)
Caused by: java.lang.NullPointerException
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 net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45)
... 24 more
The ouput of the query in db is:Code:
select bugactiv0_.bug_id as bug_id, bugactiv0_.bug_when as bug_when, bugactiv0_.fieldId as fieldId, bugactiv0_.who as who, bugactiv0_.added as added, bugactiv0_.attach_id as attach_id, bugactiv0_.removed as removed from bugs_activity bugactiv0_
The mapping file: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">
<hibernate-mapping>
<class
name="net.sf.jagzilla.hibernate.BugActivity"
table="bugs_activity"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="id"
class="net.sf.jagzilla.hibernate.BugActivityPrimaryKey"
>
<key-property
name="bugId"
type="int"
column="bug_id"
/>
<key-property
name="bugWhen"
type="java.util.Date"
column="bug_when"
/>
<key-property
name="fieldId"
type="int"
column="fieldId"
/>
<key-property
name="who"
type="int"
column="who"
/>
</composite-id>
<property
name="added"
type="java.lang.String"
update="true"
insert="true"
column="added"
/>
<property
name="attachId"
type="int"
update="true"
insert="true"
column="attach_id"
/>
<property
name="removed"
type="java.lang.String"
update="true"
insert="true"
column="removed"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-BugActivity.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
The java classes fileCode:
/*
* Created on Sep 30, 2003
*
*/
package net.sf.jagzilla.hibernate;
import java.io.Serializable;
/**
* represents a record in the table bugs_activity.
*
*
* @author mgriffa
*
* @hibernate.class
* table="bugs_activity"
*
*/
public class BugActivity implements Serializable{
private BugActivityPrimaryKey id;
private int attachId;
private String added;
private String removed;
/**
* @hibernate.property
*
* @return Returns the added.
*/
public String getAdded() {
return added;
}
/**
*
* @param added The added to set.
*/
public void setAdded(String added) {
this.added = added;
}
/**
* @hibernate.property column="attach_id"
*
* @return Returns the attachId.
*/
public int getAttachId() {
return attachId;
}
/**
* @param attachId The attachId to set.
*/
public void setAttachId(int attachId) {
this.attachId = attachId;
}
/**
* @hibernate.property
*
* @return Returns the removed.
*/
public String getRemoved() {
return removed;
}
/**
* @param removed The removed to set.
*/
public void setRemoved(String removed) {
this.removed = removed;
}
public String toString() {
return "[BugActivity: " +
"id="+id+
"attachId, ="+attachId+
"attachId, ="+attachId+
"added, ="+added+
"removed, ="+removed+
" ]";
}
/**
* @hibernate.id generator-class = "BugActivityPrimaryKey"
*
* @return Returns the id.
*/
public BugActivityPrimaryKey getId() {
return id;
}
/**
* @param id The id to set.
*/
public void setId(BugActivityPrimaryKey id) {
this.id = id;
}
}
/*
* Created on Sep 30, 2003
*
*/
package net.sf.jagzilla.hibernate;
import java.io.Serializable;
import java.util.Date;
/**
* represents the primary key for the class BugActivity.
*
* @see BugActivity
*
* @author mgriffa
*
*
*/
public class BugActivityPrimaryKey implements Serializable{
private int bugId;
private int who;
private Date bugWhen;
private int fieldId;
/**
* @hibernate.property column="bug_id"
*
* @return Returns the bugId.
*/
public int getBugId() {
return bugId;
}
/**
* @param bugId The bugId to set.
*/
public void setBugId(int bugId) {
this.bugId = bugId;
}
/**
* @hibernate.property column="bug_when"
*
* @return Returns the bugWhen.
*/
public Date getBugWhen() {
return bugWhen;
}
/**
* @param bugWhen The bugWhen to set.
*/
public void setBugWhen(Date bugWhen) {
this.bugWhen = bugWhen;
}
/**
* @hibernate.property
*
* @return Returns the fieldId.
*/
public int getFieldId() {
return fieldId;
}
/**
* @param fieldId The fieldId to set.
*/
public void setFieldId(int fieldId) {
this.fieldId = fieldId;
}
/**
* @hibernate.property
*
* @return Returns the who.
*/
public int getWho() {
return who;
}
/**
* @param who The who to set.
*/
public void setWho(int who) {
this.who = who;
}
public String toString() {
return "[BugActivityPrimaryKey: " +
"bugId="+bugId+
"who, ="+who+
"bugWhen, ="+bugWhen+
"fieldId, ="+fieldId+
" ]";
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
// TODO Auto-generated method stub
return super.equals(obj);
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
// TODO Auto-generated method stub
return super.hashCode();
}
}
Is there more info I should post?[/b]