-->
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: Can not set java.lang.Long field to java.lang.Long
PostPosted: Sat Oct 25, 2008 4:48 pm 
Newbie

Joined: Sat Oct 25, 2008 4:37 pm
Posts: 3
Hibernate version:
3.2.6.ga

Name and version of the database you are using:
MySQL 5.0

Full stack trace of any exception that occurs:
174711 [http-8080-2] FATAL de.actionlisteners.ExceptionHandler -
processAction :: #{AdministrateReceipt.createPriceList}: javax.faces.el.Evaluati
onException: /jsp/application/shoppinglist/createShoppingList.jspx @158,156 acti
on="#{AdministrateReceipt.createPriceList}": javax.persistence.PersistenceExcept
ion: org.hibernate.PropertyAccessException: could not get a field value by refle
ction getter of de.businessobjects.Product.id
javax.faces.FacesException: #{AdministrateReceipt.createPriceList}: javax.faces.
el.EvaluationException: /jsp/application/shoppinglist/createShoppingList.jspx @1
58,156 action="#{AdministrateReceipt.createPriceList}": javax.persistence.Persis
tenceException: org.hibernate.PropertyAccessException: could not get a field val
ue by reflection getter of de.businessobjects.Product.id
at com.sun.faces.application.ActionListenerImpl.processAction(ActionList
enerImpl.java:78)
at de.actionlisteners.ExceptionHandler.processAction(Unkno
wn Source)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)

at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:3
81)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicat
ionPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLife
cycleExecutor.java:17)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(Rec
eiveSendUpdates.java:54)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(Receive
SendUpdates.java:42)
at com.icesoft.faces.webapp.http.core.ViewBoundServer.service(ViewBoundS
erver.java:65)
at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVer
ifier.java:44)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Ma
tcher.serviceOnMatch(PathDispatcherServer.java:50)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.se
rvice(PathDispatcherServer.java:19)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.s
ervice(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.serv
ice(EnvironmentAdaptingServlet.java:29)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service
(MainSessionBoundServlet.java:139)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(Sessi
onDispatcher.java:35)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceO
nMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDisp
atcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet
.java:79)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica
tionDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:342)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:302)
at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServ
let.java:54)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
7)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: /jsp/application/shoppinglist/cre
ateShoppingList.jspx @158,156 action="#{AdministrateReceipt.createPriceList}": j
avax.persistence.PersistenceException: org.hibernate.PropertyAccessException: co
uld not get a field value by reflection getter of de.businessobjec
ts.Product.id
at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.ja
va:73)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionList
enerImpl.java:72)
... 42 more
Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessE
xception: could not get a field value by reflection getter of de.b
usinessobjects.Product.id
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException
(AbstractEntityManagerImpl.java:637)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:74)
at de.businessservices.ReceiptServiceImpl.createPriceList(
Unknown Source)
at de.businessservices.ReceiptServiceRemote.createPriceLis
t(Unknown Source)
at de.actionbeans.AdministrateReceipt.createPriceList(Unkn
own Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.el.parser.AstValue.invoke(AstValue.java:130)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)

at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.ja
va:68)
at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.ja
va:69)
... 43 more
Caused by: org.hibernate.PropertyAccessException: could not get a field value by
reflection getter of de.businessobjects.Product.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(Direct
PropertyAccessor.java:35)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(Abstr
actEntityTuplizer.java:183)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(
AbstractEntityPersister.java:3596)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(Ab
stractEntityPersister.java:3312)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(Fore
ignKeys.java:218)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:87)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSp
ecification.java:38)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.
java:491)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1563)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.ja
va:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java
:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:65)
... 54 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field
de.businessobjects.Product.id to java.lang.Long
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(
Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(
Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source)
at java.lang.reflect.Field.get(Unknown Source)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(Direct
PropertyAccessor.java:32)
... 75 more

The generated SQL (show_sql=true):
select
pricedata0_.id as id0_0_,
shoppingli1_.id as id4_1_,
pricedata0_.date as date0_0_,
pricedata0_.location as location0_0_,
pricedata0_.price as price0_0_,
pricedata0_.price_scout as price5_0_0_,
pricedata0_.product as product0_0_,
pricedata0_.product_unit as product7_0_0_,
shoppingli1_.position as position4_1_,
shoppingli1_.product as product4_1_,
shoppingli1_.product_unit as product5_4_1_,
shoppingli1_.quantity as quantity4_1_,
shoppingli1_.shopping_list as shopping6_4_1_
from
price_data pricedata0_,
shopping_list_item shoppingli1_
where
(
(
pricedata0_.price , pricedata0_.product , pricedata0_.product_un
it
) in (
select
min(pricedata2_.price),
pricedata2_.product,
pricedata2_.product_unit
from
price_data pricedata2_,
product product3_,
product_unit productuni4_
where
pricedata2_.product=product3_.id
and pricedata2_.product_unit=productuni4_.id
and (
pricedata2_.product in (
? , ? , ?
)
)
and (
pricedata2_.product_unit in (
? , ? , ?
)
)
group by
pricedata2_.product
)
)
and shoppingli1_.shopping_list=578
and pricedata0_.product=shoppingli1_.product
and pricedata0_.product_unit=shoppingli1_.product_unit
group by
pricedata0_.product

Problem:
Does anybody know what the problem is?
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field
de.businessobjects.Product.id to java.lang.Long

This exception message makes no sense to me.


Top
 Profile  
 
 Post subject: Solution
PostPosted: Tue Oct 28, 2008 8:42 am 
Newbie

Joined: Sat Oct 25, 2008 4:37 pm
Posts: 3
I found the solution by myself. I post it here. Perhaps it helps other peoples out of trouble.

The problem was that the field of the object which i used was an object itself and I did not specifiy the field of the object.

In short:

This section in the SQL:

Code:
pricedata2_.product in (
? , ? , ?
)
)
and (
pricedata2_.product_unit in (
? , ? , ?
)
)


need to be look like this:

Code:
pricedata2_.product.id in (
? , ? , ?
)
)
and (
pricedata2_.product_unit.id in (
? , ? , ?
)
)


Another example:
Pricedata has a many to one relationshipt to product
snippet from pricedata object:

....
@ManyToOne
@JoinColumn("product")
private Product product;

Wrong:
Select pd from priceData pd where pd.product in (100, 200);
Right:
Select pd from priceData pd where pd.product.id in (100, 200);


Top
 Profile  
 
 Post subject: Solution
PostPosted: Tue Oct 28, 2008 8:43 am 
Newbie

Joined: Sat Oct 25, 2008 4:37 pm
Posts: 3
I found the solution by myself. I post it here. Perhaps it helps other peoples out of trouble.

The problem was that the field of the object which i used was an object itself and I did not specifiy the field of the object.

In short:

This section in the SQL:

Code:
pricedata2_.product in (
? , ? , ?
)
)
and (
pricedata2_.product_unit in (
? , ? , ?
)
)


need to be look like this:

Code:
pricedata2_.product.id in (
? , ? , ?
)
)
and (
pricedata2_.product_unit.id in (
? , ? , ?
)
)


Another example:
Pricedata has a many to one relationshipt to product
snippet from pricedata object:

....
@ManyToOne
@JoinColumn("product")
private Product product;

Wrong:
Select pd from priceData pd where pd.product in (100, 200);
Right:
Select pd from priceData pd where pd.product.id in (100, 200);


Top
 Profile  
 
 Post subject: Thank you
PostPosted: Mon Dec 29, 2008 4:26 pm 
Newbie

Joined: Mon Dec 29, 2008 4:23 pm
Posts: 1
Thank you very much. I had the same problem. It is so easy to solve that I was not seeing it...


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.