[jboss-user] [JBoss Seam] - @Formula Hibernate error
anescu
do-not-reply at jboss.com
Wed Nov 15 11:11:26 EST 2006
Hi,
I modified the seam issue tracking example, I have 2 entities, Type & Expense. Expense has a value field, of type Integer. In the Type entity I have a field expenseValue which should keep the sum of all the Expenses for a Type.
The code looks like this:
@Formula("(select sum(i.value) from Expense i where i.type_name = name)")
public int getExpenseValue()
{
return expenseValue;
}
The result should be displayed on the Type list (first page that gets displayed). I get an error with this stacktrace:
If I change the type from int to Integer its working, but I get no value on the types that have no expenses.
Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of org.jboss.seam.example.issues.Type.expenseValue
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:641)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
at org.jboss.seam.example.issues.TypeFinderBean.executeQuery(TypeFinderBean.java:39)
at org.jboss.seam.example.issues.TypeFinderBean.findTypes(TypeFinderBean.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
......
... 80 more
Caused by: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of org.jboss.seam.example.issues.Type.expenseValue
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:85)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3499)
I use JBossAS 4.0.5 (from jems installer, EJB3 config) and Seam GA 1.0.1.
I can send you the code, if necessary. Is this a bug or am I missing something?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986189#3986189
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986189
More information about the jboss-user
mailing list