Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Related Mapping in ColdFusion
PostPosted: Tue Aug 22, 2017 7:17 am 
Newbie

Joined: Tue Aug 22, 2017 6:52 am
Posts: 6
Good afternoon,

I'm working in Adobe ColdFusion, which uses Hibernate for its ORM functionality. I've only recently started diving into the ORM universe but it seems like on the whole it's a massive time-saver! I'm just having one issue at the moment - saving an entity with an updated foreign key value.

I have already asked a similar question on this topic on Stack Overflow, but since that point I'm starting to think the question may be more one for the Hibernate community than the ColdFusion one. The stripped-down example I gave on that question still applies, but here are similar example components for ease:

Template.cfc
Code:
component persistent="true" table="template"{

    property name="id"              type="numeric"   column="templateID"         fieldtype="id"              generator="identity";
    property name="userID"          type="numeric"   fkcolumn="userID"           fieldtype="many-to-one"     cfc="User";
    property name="lastModified"    type="date"      column="lastModified";

}


User.cfc
Code:
component persistent="true" table="user"{

    property name="id"          type="numeric"    column="userID"     fieldtype="id"     generator="identity";
    property name="username"    type="string"     column="username";
    property name="password"    type="string"     column="password";

}


Whenever I flush the ORM (I think this is what triggers it anyway - it's when the program attempts to update the DB) and I update template.userID I get an exception thrown, but the message is just 'java.lang.Integer' (this is the type I'm passing it, since the DB field is type 'int'). When I remove the many-to-one relationship it seems to work, making me think the issue is either with the relational mapping itself (but 'gets' work even when 'sets' don't, so probably not), the target field (again, though, gets work...) or what Hibernate has worked out the field type as.

Looking at the error dump, I can see:
CF Application error (detail: The root cause of this exception was: coldfusion.orm.hibernate.HibernateSessionException: Property : userID - java.lang.Integer.)
caused by java.lang.ClassCastException (message: java.lang.integer)
caused by org.hibernate.HibernateException (message: Property : userID - java.lang.Integer)


Now, as I said on SO, I understand CF has a number of problems when dealing with integers, but doing a type check on the line before calling the implicit setter on userID shows it as java.lang.Integer, which is the closest CF can possibly manage to an int.

Fun fact (not sure if this affects anything) - the db table was not created by ORM, but was already in existence when the ORM in CF was created.

I'm at the point now all I have looping in my head is "it wants an integer, I'm giving it an integer". I assume soon I'll be waking up in a cold sweat screaming "what do you want from me?" or something, but I'm also aware it may just be I've made a stupid error somewhere.

Any and all help will be greatly appreciated

Many thanks

Cush


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Wed Aug 23, 2017 5:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1432
You should ask this question on the ColdFusion error because, although they build on top of Hibernate, it's still a different product. Their community can help you better since, with all the Hibernate knowledge, I have no clue what does ColdFusion behind the scenes.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Wed Aug 23, 2017 9:47 am 
Newbie

Joined: Tue Aug 22, 2017 6:52 am
Posts: 6
Hi Vlad,

Thanks for your suggestion, but we have an Enterprise licence with platinum support on top and their support agent still wasn't able to do anything about it. I think I won the 'bad support agent' lottery in that specific case, but as it stands they can't help.

Can you at least assist at all in what the issue might be? For example, what the Hibernate part of the error stack is suggesting?


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Wed Aug 23, 2017 9:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1432
Quote:
Can you at least assist at all in what the issue might be? For example, what the Hibernate part of the error stack is suggesting?


HibernateException is a generic exception, so you need to provide a Hibernate stack trace to get more info. However, it's probably better to just debug it and see what's happening behind the scenes.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Thu Aug 24, 2017 2:23 pm 
Newbie

Joined: Tue Aug 22, 2017 6:52 am
Posts: 6
Ah, see I thought that might be the case but I thought the message might help identify a bit better what's going on.

I'll get a stack trace tomorrow when I'm back in the office (LAN access only to the server in question).

Thanks


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Fri Aug 25, 2017 4:31 am 
Newbie

Joined: Tue Aug 22, 2017 6:52 am
Posts: 6
This is the stack trace I get when passing a java.lang.Integer into the integer field:

Code:
java.lang.ClassCastException: java.lang.Integer at coldfusion.runtime.Cast._cast(Cast.java:253) at coldfusion.orm.ORMUtils.getTypedValue(ORMUtils.java:363) at coldfusion.orm.hibernate.CFCPropertyGetter.get(CFCPropertyGetter.java:72) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValues(AbstractEntityTuplizer.java:608) at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:4726) at org.hibernate.event.internal.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:195) at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:152) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258) at coldfusion.orm.hibernate.SessionWrapper.flush(SessionWrapper.java:190) at coldfusion.orm.hibernate.HibernatePersistenceManager.onCommit(HibernatePersistenceManager.java:963) at coldfusion.orm.hibernate.HibernatePersistenceManager$HibernateEventListener.onCommit(HibernatePersistenceManager.java:1114) at coldfusion.tagext.sql.TransactionTag.fireOnCommit(TransactionTag.java:743) at coldfusion.tagext.sql.TransactionTag.commit(TransactionTag.java:401) at coldfusion.tagext.sql.TransactionTag.doEndTag(TransactionTag.java:300) at cfindex2ecfm1339969791._factor7(E:\ftphome\sdcwww\git\dev\james\forms\example\index.cfm:293) at cfindex2ecfm1339969791._factor10(E:\ftphome\sdcwww\git\dev\james\forms\example\index.cfm:287) at cfindex2ecfm1339969791._factor13(E:\ftphome\sdcwww\git\dev\james\forms\example\index.cfm:141) at cfindex2ecfm1339969791._factor18(E:\ftphome\sdcwww\git\dev\james\forms\example\index.cfm:5) at cfindex2ecfm1339969791._factor19(E:\ftphome\sdcwww\git\dev\james\forms\example\index.cfm:1) at cfindex2ecfm1339969791.runPage(E:\ftphome\sdcwww\git\dev\james\forms\example\index.cfm:1) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:251) at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:479) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:43) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:142) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:151) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at coldfusion.inspect.weinre.MobileDeviceDomInspectionFilter.doFilter(MobileDeviceDomInspectionFilter.java:121) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:532) at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:874) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)


Edit: I know the top item on the stack after the variable type is coldfusion.runtime.Cast._cast(Cast.java:253) but I'm just hoping the Hibernate entries in there might help debug the issue - CF support are really struggling to understand the issue, let alone fix it


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Fri Aug 25, 2017 4:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1432
It's Coldfusion:

Code:
coldfusion.orm.ORMUtils.getTypedValue(ORMUtils.java:363)


not Hibernate throwing the exception. So, only a CF expert can help you with that.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Fri Aug 25, 2017 9:11 am 
Newbie

Joined: Tue Aug 22, 2017 6:52 am
Posts: 6
Cush wrote:
Edit: I know the top item on the stack after the variable type is coldfusion.runtime.Cast._cast(Cast.java:253) but I'm just hoping the Hibernate entries in there might help debug the issue - CF support are really struggling to understand the issue, let alone fix it


Do you see anything at all in the hibernate entries there which can help? Just information about what's going on in the back end or anything?


Top
 Profile  
 
 Post subject: Re: Related Mapping in ColdFusion
PostPosted: Thu Aug 31, 2017 10:54 am 
Newbie

Joined: Tue Aug 22, 2017 6:52 am
Posts: 6
I guess not.

Well, in case anyone else is interested, or you want to help people who post here in future having the same issue, Adobe support eventually sorted it out (emphasis on 'eventually') and I've answered the SO question accordingly:

https://stackoverflow.com/questions/458 ... 7#45984417


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.