> i have written a testcase for this and i have seen that this is working in
> ACF, we will do some deeper tests, to check if my first conclusion is right
> or not.
> can you please open a ticket for this in Jira
https://issues.jboss.org/browse/RAILO
> tnx micha
> 2012/2/21 Chris Blackwell <ch...@team193.com>
> > Thanks micha, that was the clue i needed.
> > instead of use cfquery, i can use ormGetSession() and execute my query on
> > hibernates connection.
> > Many thanks
> > Chris
> > On 20 February 2012 19:04, Michael Offner <mich...@getrailo.com> wrote:
> >> a transaction tag does not use/create a connection, a transaction tag
> >> only change the rules for the connections inside.
> >> what you mean is that orm and cfquery use separate connections. we cannot
> >> change this, hibernate mess a lot with the given connection and we have
> >> only limited control over this. use the same connection for cfquery could
> >> produce serious problems.
> >> /micha
> >> 2012/2/20 Chris Blackwell <ch...@team193.com>
> >>> I would have assumed that a query inside a transaction would use the
> >>> same connection as the transaction, but your saying its trying to open a
> >>> new connection?
> >>> - Chris
> >>> On 20 Feb 2012 08:15, "Michael Offner" <mich...@getrailo.com> wrote:
> >>>> tis is expected behavior, cftransaction can only handle one connection
> >>>> inside
> >>>> /micha
> >>>> 2012/2/18 Chris Blackwell <ch...@team193.com>
> >>>>> Hey guys,
> >>>>> I'm trying to assign my ORM id's manually, the id is generated by a
> >>>>> udf in MySQL.
> >>>>> the relevant bits of my entity are -
> >>>>> property name="ID" fieldtype="id" generator="assigned" update="false"
> >>>>> setter="false";
> >>>>> //this is required or you get an error about assigning an id prior to
> >>>>> calling save
> >>>>> variables.id = "";
> >>>>> public void function preInsert() {
> >>>>> if(!len( variables.id )) {
> >>>>> variables.id = new query(sql="select newid() as
> >>>>> id").execute().getResult().id;
> >>>>> }
> >>>>> }
> >>>>> Then if i do
> >>>>> transaction {
> >>>>> u = new model.entity.User();
> >>>>> entitySave(u);
> >>>>> }
> >>>>> I get the error "*can't use different connections inside a transaction
> >>>>> *". Its obvious that this is being caused by the sql query being
> >>>>> executed in preInsert, but i'm curious if this is the expected behaviour or
> >>>>> a bug, and if there's a way to work around the issue or refactor to avoid
> >>>>> it all together.
> >>>>> Cheers, Chris
> >>>>> Full stack trace
> >>>>> can't use different connections inside a transaction
> >>>>> at
> >>>>> railo.runtime.db.DatasourceManagerImpl.getConnection(DatasourceManagerImpl. java:66):66
> >>>>> at railo.runtime.tag.Query.executeDatasoure(Query.java:616):616
> >>>>> at railo.runtime.tag.Query.doEndTag(Query.java:474):474
> >>>>> at
> >>>>> org.railo.cfml.base_cfc$cf._1(D:\git-repos\project\webroot\WEB-INF\railo\co mponents\org\railo\cfml\Base.cfc:148):148
> >>>>> at
> >>>>> org.railo.cfml.base_cfc$cf.udfCall(D:\git-repos\project\webroot\WEB-INF\rai lo\components\org\railo\cfml\Base.cfc):-1
> >>>>> at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215
> >>>>> at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434
> >>>>> at railo.runtime.type.UDFImpl.call(UDFImpl.java:384):384
> >>>>> at
> >>>>> railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(Variable UtilImpl.java:738):738
> >>>>> at
> >>>>> railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1443):1443
> >>>>> at
> >>>>> org.railo.cfml.query_cfc$cf.udfCall(D:\git-repos\project\webroot\WEB-INF\ra ilo\components\org\railo\cfml\Query.cfc:35):35
> >>>>> at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215
> >>>>> at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434
> >>>>> at railo.runtime.type.UDFImpl.call(UDFImpl.java:384):384
> >>>>> at railo.runtime.ComponentImpl._call(ComponentImpl.java:615):615
> >>>>> at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502
> >>>>> at railo.runtime.ComponentImpl.call(ComponentImpl.java:1815):1815
> >>>>> at
> >>>>> railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(Variable UtilImpl.java:733):733
> >>>>> at
> >>>>> railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1443):1443
> >>>>> at
> >>>>> web_inf180.app.model.entity.abstractentity_cfc$cf._2(D:\git-repos\project\w ebroot\WEB-INF\app\model\entity\AbstractEntity.cfc:123):123
> >>>>> at
> >>>>> web_inf180.app.model.entity.abstractentity_cfc$cf.udfCall(D:\git-repos\proj ect\webroot\WEB-INF\app\model\entity\AbstractEntity.cfc):-1
> >>>>> at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215
> >>>>> at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434
> >>>>> at railo.runtime.type.UDFImpl.call(UDFImpl.java:384):384
> >>>>> at railo.runtime.ComponentImpl._call(ComponentImpl.java:615):615
> >>>>> at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502
> >>>>> at railo.runtime.ComponentImpl.call(ComponentImpl.java:1815):1815
> >>>>> at
> >>>>> railo.runtime.orm.hibernate.event.EventListener.invoke(EventListener.java:9 4):94
> >>>>> at
> >>>>> railo.runtime.orm.hibernate.event.InterceptorImpl.on(InterceptorImpl.java:6 7):67
> >>>>> at
> >>>>> railo.runtime.orm.hibernate.event.InterceptorImpl.onSave(InterceptorImpl.ja va:46):46
> >>>>> at
> >>>>> org.hibernate.event.def.AbstractSaveEventListener.substituteValuesIfNecessa ry(AbstractSaveEventListener.java:414):414
> >>>>> at
> >>>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(Ab stractSaveEventListener.java:293):293
> >>>>> at
> >>>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveE ventListener.java:204):204
> >>>>> at
> >>>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(Abstr actSaveEventListener.java:144):144
> >>>>> at
> >>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedO rRequestedId(DefaultSaveOrUpdateEventListener.java:210):210
> >>>>> at
> >>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient( DefaultSaveOrUpdateEventListener.java:195):195
> >>>>> at
> >>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdat e(DefaultSaveOrUpdateEventListener.java:117):117
> >>>>> at
> >>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(Def aultSaveOrUpdateEventListener.java:93):93
> >>>>> at
> >>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:677):677
> >>>>> at
> >>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:669):669
> >>>>> at
> >>>>> railo.runtime.orm.hibernate.HibernateORMSession.save(HibernateORMSession.ja va:165):165
> >>>>> at railo.runtime.functions.orm.EntitySave.call(EntitySave.java:16):16
> >>>>> at railo.runtime.functions.orm.EntitySave.call(EntitySave.java:11):11
> >>>>> at
> >>>>> tests.scratch._5_cfm$cf.call(D:\git-repos\project\webroot\tests\scratch\5.c fm:4):4
> >>>>> at
> >>>>> railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:761):761
> >>>>> at
> >>>>> railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java: 179):179
> >>>>> at
> >>>>> railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:23) :23
> >>>>> at
> >>>>> railo.runtime.PageContextImpl.execute(PageContextImpl.java:1998):1998
> >>>>> at
> >>>>> railo.runtime.PageContextImpl.execute(PageContextImpl.java:1965):1965
> >>>>> at
> >>>>> railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:297):29 7
> >>>>> at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:32):32
> >>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722):722
> >>>>> at
> >>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio nFilterChain.java:305):305
> >>>>> at
> >>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC hain.java:210):210
> >>>>> at
> >>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j ava:224):224
> >>>>> at
> >>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j ava:169):169
> >>>>> at
> >>>>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBas e.java:472):472
> >>>>> at
> >>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:16 8):168
> >>>>> at
> >>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98 ):98
> >>>>> at
> >>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav a:118):118
> >>>>> at
> >>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) :407
> >>>>> at
> >>>>> org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200
> >>>>> at
> >>>>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Abstra ctProtocol.java:539):539
> >>>>> at
> >>>>> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java :298):298
> >>>>> at
> >>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.j ava:886):886
> >>>>> at
> >>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 908):908
> >>>>> at java.lang.Thread.run(Thread.java:662):662