Hi Everyone, Is there a convenient way that I can ...
# docker-commandbox
g
Hi Everyone, Is there a convenient way that I can uninstall the ortus hibernate extension and install the Lucee 3.5.5.x one( we cannot use 5,x - yet) That doesn;t require me to use a dockerfile and re-create the image? I am using docker compose to join in a DB and mailserver container to the commandbox image. But compose doesn't support "copy" - so I can't stick it in the deploy folder. I also tried by specifiying the LUCEE_EXTENSION env variable - but that didn't work. I am using the psuedo constructor of Application.cfc and the adminAPI to uninstall then adds in the one I want. so I have the app working - now - but I'd rather it wasnt in the code.
b
@gavinbaumanis Missing information here. What version of Lucee are you starting and where is it coming from?
We haven't done anything to add the Ortus ORM extension to the Lucee CF engines on ForgeBox, and don't plan to
So if you're just starting a random version of LUcee from forgebox, then Ortus ORM will not be installed
We are bundling it just for CommandBox version 5.9.1 in the actual CLI Lucee instance, so if you start a server just using the default version of Lucee that's baked into the CLI that would be the only way you'd get it.
I don't believe Lucee provides any way to automatically "uninstall" an extension, which is a little lame, but when it was brought up in the past, they didn't think there was a valid use case for it 🤷
g
Hi Brad thanks very much for getting back to me. I am using the ortussolutions/commandbox image (no tags). I was hopeful that there might have been a step that I was missing / didn't know about that could help with installing an extension, using the "base" image and a docker compose file. I do understand that I could use a dockerFile and create my own image... Which is the path I guess I am going to have to use.. - was just trying to avoid it.
b
That... didn't answer my question.
g
"Whatever" version is being used by the default commandbox image. so currently it is 5.4.3.2 I am not specifying a version - or even the Lucee tag.
b
So just add a version to your server.json so it pulls the non-default version.
No need to make your own image for that.
Or via env var
g
The issue I seem to be having is; If I use ortusolutions/commandbox:lucee5 Then, trying to install the extensions that I want via LUCEE_EXTENSIONS env var does not work. And because I am only using docker-compose without a dockerfile, I don't have a COPY command available to me to place the extensions I want in the deploy directory.
which is why I went back a step the non-warmed up verison.
Hold on... I think the penny has dropped.... • Use the generic tag • Have a server.json in my appRoot - that has the engine version / extensions / etc...
So now - the only issue I have is the installed extensions that I don't need... Which I can get rid of via the adminAPI - at the moment... - if it bothers me enough.
b
You could also just use the light version of Lucee and then add in only what you want
👍🏼 1
Which is LAS's official solution to this
g
I am not sure why I was making it sooo difficult for myself. As always - thanks very much for your help! I really appreciate it.
j
@gavinbaumanis In the pre-warmed
:lucee5
tag, which uses Lucee 5.4, the Ortus ORM extension is present. That is due to Lucee no longer bundling the ORM extension and wanting to make sure the ORM functionality is available - so as not to break existing implementations. The 3.5 Lucee extension has a number of know CVE’s and, as such, it presents a vulnerability. Same with Lucee’s 5.x version. If I may ask, what’s preventing you from moving to the newer Hibernate version?
g
HI @jclausen - Thanks for reaching out. When I attempt to use the 5.x extension I get exception errors. I haven;t had any time to look into what I need to do change to make our app work with 5.x - so I have just left it at 3.x until I can get to it.
I am just restarting our app now with the lucee5 tag - so I'll be able to tell you the error we get in a minute.
Here is an error we get with 5.x
Copy code
"ERROR","XNIO-1 task-3","09/25/2023","23:47:34","","No data type for node: org.hibernate.hql.ast.tree.IdentNode 
 +-[IDENT] IdentNode: 'received_date' {originalText=received_date}
;lucee.runtime.exp.NativeException: No data type for node: org.hibernate.hql.ast.tree.IdentNode 
 +-[IDENT] IdentNode: 'received_date' {originalText=received_date}

	at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:154)
	at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:845)
	at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:633)
	at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:678)
	at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:294)
	at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:237)
	at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
	at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
	at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
	at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:98)
	at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
	at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
	at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1760)
	at org.lucee.extension.orm.hibernate.HibernateORMSession.__executeQuery(HibernateORMSession.java:452)
	at org.lucee.extension.orm.hibernate.HibernateORMSession._executeQuery(HibernateORMSession.java:431)
	at org.lucee.extension.orm.hibernate.HibernateORMSession.executeQuery(HibernateORMSession.java:421)
	at ortus.extension.orm.functions.ORMExecuteQuery._call(ORMExecuteQuery.java:85)
	at ortus.extension.orm.functions.ORMExecuteQuery.call(ORMExecuteQuery.java:70)
	at ortus.extension.orm.functions.ORMExecuteQuery.invoke(ORMExecuteQuery.java:121)
	at lucee.runtime.functions.FunctionHandlerPool.invoke(FunctionHandlerPool.java:40)
	at model.uploadsmodel_cfc$cf.udfCall(/gsncfc/model/uploadsModel.cfc:136)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:586)
	at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1933)
	at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
	at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775)
	at service.uploadsservice_cfc$cf.udfCall(/gsncfc/service/uploadsService.cfc:28)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:586)
...
"
j
That looks like something specific to the updated version of hibernate. @mborn Any thoughts?
What does the code look like here:
model/uploadsModel.cfc:136
?
g
Copy code
local.b = ORMExecuteQuery("
					SELECT #local.fieldNames#
					FROM #local.emailRecipientsDS.getInternalName()#
					WHERE dataSourceRecord = :fileId
				", {fileId = local.p.fileId}, false, {datasource=entityLoadByPK('customer',local.p.customerId).getDataSource()});

				return {headings: local.fieldNames, data: local.b, fileName: #listLAst(local.a[1],"/\")#};
j
I think I possibly know the issue: Are
local.fieldNames
all the correct property casing and is
local.emailRecipientsDS.getInternalName()
the same with the casing?
g
Sorry Jon I am not following.
j
Once you go off in to hibnerate/java land, things get case sensitive ( e.g. entity names, property names, etc. )
g
Here is the whole function...
Copy code
public struct function getRecipientsForFile(required struct formStruct) {
		local.p = {
			customerId = arguments.formStruct["customerId"]
		};

		if(isNumeric(arguments.formStruct["datasourceId"]) && arguments.formStruct["datasourceId"] != 0
            && isNumeric(arguments.formStruct["fileId"]) && arguments.formStruct["fileId"] != 0 ) {

			// Use the dataSourceId to find the survey
			local.lookUp = ORMExecuteQuery("
				FROM ws_survey s
				WHERE s.sysDataSourceId = :dataSourceId
			", {dataSourceId = arguments.formStruct["dataSourceId"]}, false, {dataSource = "GSN_WebSurvey"} );

			if(arrayLen(local.lookUp) != 1) {

				// This should not happen: every DS is for a (deployed) survey
				return {headings:"", data:[], fileName:""};
			} else {

				local.surveyId = local.lookUp[1].getSurveyId();

				local.q = " AND ds1.dataSourceId = :dataSourceId AND dsr.fileName LIKE '%_sid_#local.surveyId#%' AND dsr.dataSourceRecordId = :fileId";
				local.p.dataSourceId = arguments.formStruct["dataSourceId"];
				local.p.fileId = arguments.formStruct["fileId"];
			}

			// Nothing more than a sanity check, really...
			local.a = ORMExecuteQuery("
				SELECT dsr.fileName
				FROM dataSourceRecord dsr
				JOIN dsr.dataSource ds
				JOIN ds.customer c
				JOIN c.datasources ds1
				WHERE c.customerId = :customerId #local.q#
			", local.p);

			if(arrayLen(local.a) == 1) {

				// Every tenant has a single one of these.
				local.emailRecipientsDS = entityLoadByPK('customer',local.p.customerId).getEmailRecipientDS()[1];

				// What are the fields of interest?
				local.fieldNames = "";

				for(local.f in local.emailRecipientsDS.getOriginalDataFields()) {

					local.fieldNames = listAppend(local.fieldNames, local.f[1]);
				}

				// Pull the data
				local.b = ORMExecuteQuery("
					SELECT #local.fieldNames#
					FROM #local.emailRecipientsDS.getInternalName()#
					WHERE dataSourceRecord = :fileId
				", {fileId = local.p.fileId}, false, {datasource=entityLoadByPK('customer',local.p.customerId).getDataSource()});

				return {headings: local.fieldNames, data: local.b, fileName: #listLAst(local.a[1],"/\")#};
			} else {

				// This should not happen: we should be able to identify a unique dataSourceRecord record!
				return {headings:"", data:[], fileName:""};
			}
		}
	}
j
I would suggest dumping out
local.fieldNames
and make sure they are all: 1. actual properties of the
local.emailRecipientsDS.getInternalName()
entity and not column names 2. have exactly the same casing as the defined property names in the component. Hibernate 3 would allow you to get by with column names HQL. Versions 4+ ( The Ortus extension is on 5 ) are much more strict.
g
Right. Ok Thanks Jon. Is extension v7.0.x - still hibernate 5?
After upgrading to the latest v7 snapshot I get the following:
Copy code
org.hibernate.exception.GenericJDBCException: Could not read entity state from ResultSet : EntityKey[license#1]
j
There’s something in the
license
property in the first result that is blowing up. Is that a formula property or a standard column property?
Search the stack trace for “Caused by” The last match of that usually gives you more info
g
Hi Jon, I am just reverting back to 3.5.5 - to see if the original error I posted still happens there, too. I think I t might - because in the fieldnames variable - there is a column name that does not exist in the database or in the CFC properties. So I think that was just a coincidental find of a real bug.
☝️ 1
OK - the first issue about "received_date" - is "just" a bug - not ORM related.
@jclausen Can I just confirm that likely issues (of upgrading to Hibernate 5 from 3) are that if I am using ormExecuteQuery... That I need to ensure that I am using Property names NOT db column names and that I should treat them (property names) as case sensitive?
☝️ 1
j
Yes, for sure.
m
@gavinbaumanis sorry to be late to the party... • the Ortus ORM Extension has been on Hibernate 5.6 since v6.2.0. • You should definitely watch for case sensitivity and use the correct property names (not column names). 👍
g
And just to clarify please that v6 (or 7) of the ortus ORM extension is for Hibernate v5.x? YOUR v6 is NOT for hibernate 6?
m
And just to clarify please that v6 (or 7) of the ortus ORM extension is for Hibernate v5.x?
Correct: "the Ortus ORM Extension has been on Hibernate 5.6 since v6.2.0." We broke away from synced version numbers in extension v6.2.0 to allow us to make breaking changes in the extension. (Not that there have been many... see the release notes.) Extension v7 is not out/stable yet, only snapshot builds are up, but you definitely won't see a jump to Hibernate 6 for some time.
👍🏼 1
I updated the docs to clearly state which versions of Hibernate are bundled: https://orm-extension.ortusbooks.com/#current-hibernate-version
👍🏼 1