coldbox-modules / cborm Goto Github PK
View Code? Open in Web Editor NEWThe ColdBox ORM enhancements for ColdFusion ORM & Hibernate. Make ORM not suck!
Home Page: https://coldbox-orm.ortusbooks.com/
The ColdBox ORM enhancements for ColdFusion ORM & Hibernate. Make ORM not suck!
Home Page: https://coldbox-orm.ortusbooks.com/
Change populate() in ActiveEntity so the target is the last argument so you can just pass a struct as the first argument
When I ran the box install cborm
command in commandbox it throws an error as it can't download the module due to a 404 on the project.
Therefore, I went to forgebox to download the module and clicked download which takes you to a 404:
https://github.com/ColdBox/cbox-cborm/raw/master/distributions/cborm1.0.0.zip
If I browse to the project and download zip directly the path is https://github.com/ColdBox/cbox-cborm/archive/master.zip
See the repo for the test case: https://github.com/elpete/cborm-lucee-5-error
The quick version: on Lucee 5 entitySave( myEntity )
works while myEntity.save()
does not. myEntity.save()
works on Lucee 4 without modification.
The error:
Messages: lucee.runtime.orm.ORMDatasourceConnection cannot be cast to lucee.runtime.db.DatasourceConnectionImpl
This line prevents ColdBox from starting on Lucee 5. Not sure if it is a fix here or in WireBox, but wanted to create the issue nonetheless.
When using criteria.maxResults(10) I was having a strange error on cborm/models/sql/SQLHelper.cfc line 202.
After some debugging I found out that we have a global udf function called 'factory' and it was taking this function instead of the local var.
I had to scope the factory variable like variables.factory.
Since "factory" can be a wide used variable or function name, I think it should be var scoped on cborm/models/sql/SQLHelper.cfc. Same could happen with other component variables
Add a method in Restrictions.cfc
for isNotIn
which wraps the isIn
statement in an isNot
:
any function isNotIn(required string property, required any propertyValue){
// infalte to array if simple values
if( isSimpleValue(arguments.propertyValue) ){ arguments.propertyValue = listToArray( arguments.propertyValue); }
return isNot( variables.restrictions.in(arguments.property, arguments.propertyValue) );
}
line 1075 if( !arrayContainsNoCase(realPropertyNames,thisGrammar) ) {
arrayContainsNoCase is a BD func. Adobe CF10 doesn't have this. neither does CF11
Look at pull request: #12
Make the save() operation return the saved entity or array of entities instead of the BaseORM service so you can full entity chaining
The java method accepts params and typing of params ( https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/criterion/Restrictions.java#L463 ), while the CBORM implementation accepts only the first argument of an SQL strings.
Implement the ability for the method to accept an array of params as the second argument and either auto-type or allow a third argument of types.
This will allow search building which might require native DBMS functionality to stay SQL injection-safe
exists()
in BaseORMService
is not universally functional because the property name of id
is hard coded in to the HQL.
In addition, this method will not work on entities which have an entity name which is a reserved word in the DBMS platform ( e.g. Case
).
The key property should be dynamically retrieved for the HQL in ormExecuteQuery
.
In addition, investigate if there is a ways to provide escaping for entities and property names which are reserved words : e.g [Case]
for SQL Server, "Case"
for MySQL and Postgres, etc
CBORM causes an error on Lucee 5.3.9.141 because lucee.commons.io.log.log4j.layout.ClassicLayout
no longer exists.
See https://github.com/coldbox-modules/cborm/blob/development/models/util/ORMUtilSupport.cfc#L32-L39:
/**
* Redirect all Hibernate logs to system.out
*/
if ( listFindNoCase( "Lucee", server.coldfusion.productname ) ) {
var printWriter = getPageContext().getConfig().getOutWriter();
var layout = createObject( "java", "lucee.commons.io.log.log4j.layout.ClassicLayout" );
var consoleAppender = createObject( "java", "lucee.commons.io.log.log4j.appender.ConsoleAppender" ).init(
printWriter,
layout
);
hibernateLog.addAppender( consoleAppender );
writeDump( var = "** Lucee Hibernate Logging Redirected", output = "console" );
}
It appears this moved to lucee.commons.io.log.log4j2.layout.ClassicLayout
.
Ditto for lucee.commons.io.log.log4j.appender.ConsoleAppender
, which moved to lucee.commons.io.log.log4j2.appender.ConsoleAppender
In BaseORMService.cfc around line 1055 is this chunk of code:
var methodGrammars = REMatchNoCase( "((?!(and|or|$))\w)+(#ALL_CONDITIONALS_REGEX#)?(and|or|$)", method );
Let's say you have an entity with properties of handle and sport and name and you attempt a Dynamic Finder like this findAllByHandleAndSportAndName('a','b','c');
Then it will split it up like this:
Array | |
---|---|
1 | Hand |
2 | leAnd |
3 | Spor |
4 | tAnd |
5 | Name |
I think it should have done this:
Array | |
---|---|
1 | HandleAnd |
2 | SportAnd |
3 | Name |
I haven't been able to fix that RegEx yet with the negative lookahead and would appreciate some assistance. @sigmaprojects did some related work in #4. Also there was some related discussion in the ColdBox Google Group a while back.
Using the merge function doesn't seems to attach the specified entity to the session.
BaseORMService.merge(entity)
is using Coldfusion's entityMerge which returns a new object attached to the session. However, the original object passed as an argument will not be attached.
Did I do something wrong or misunderstood how the framework is working?
On a side note, the doc specifies that the merge() function returns void which isn't correct.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.