Visit my personal home page przemeknowak.com π
pnowy / nativecriteria Goto Github PK
View Code? Open in Web Editor NEWUltra lightweight lib to generate dynamic SQL based on hibernate session
Home Page: http://nativecriteria.przemeknowak.com
Ultra lightweight lib to generate dynamic SQL based on hibernate session
Home Page: http://nativecriteria.przemeknowak.com
Visit my personal home page przemeknowak.com π
In order to support convenient way of Pageable support the SpringNativeCriteria should be extended about methods which return the Page with results.
The library gets marked red during security scan due to vulnearbility CVE-2022-22965
https://www.cvedetails.com/cve/CVE-2022-22965/
Sometime happens that we want to add the custom SQL on some specific place of query. It would be good to support that kind of approach and allows the user to add implementation of expression on each place of API
Consider to add the additional spring profile on nativeCriteria-test module which will run the test on the PostgreSQL db on demand in order to check whether it works correctly.
NativeCriteria version = 2.0
Intend to form a statement = select top 100 col1, col2 from tableA
Using
NativeExps.customSql( "TOP 100")
or
NativeExps.sql( "TOP 100" )
will result in an extra comma:
select top 100, col1, col2 from tableA
Extend tests about the memory db testing (it could be H2 with liquibase or hibernate auto DLL entities and example database schema)
Add the support for custom Common Table Expressions and check how it works with createNativeSqlQuery from hibernate session.
Create native expression which use lowercase(column) to like search. Sometimes it is useful, especially when database does not support ILIKE expression.
It would be good to add support on NativeBeanPropertyMapper for embedded objects.
Let's assume that we have the class ProductDTO with embedded class Category. Currently we could map only simple types. Bean property mapper could fill the categoryId on ProductDTO but doesn't create the category object and fill id inside Category.
This ticket has been created in order to add that kind of support.
We could use specific notation for this in out aliases, something like that:
c.id as category$id
in order to parser know that object should be created.
Before the release of 2.0 version upgrade the Spring Boot dependency to 1.3 version.
It would be good to have bean property row mapper which based on the aliases set the beans properties.
When someone use custom query in where clause the additional comma is being added (as a separator between others not-custom expressions). This comma shouldn't be added for custom sql-s.
Use couscous.io for documentation
Migrate library to Java8 version
Hello,
I have found a bug in expressions. NativeNotLikeExp, NativeNotILikeExp. They don`t use varName variable. As a result I am getting error
javax.persistence.PersistenceException: org.hibernate.engine.query.ParameterRecognitionException: Mixed parameter strategies - use just one of named, positional or JPA-ordinal strategy
Hi
May I know how to construct a sql as below?
SELECT * FROM aTable ORDER BY NEWID()
I tried to use NativeOrderExps but notice that it didn't take in a sql expression.
Thanks
Ian Lim
Add checkstyle rules in order to keep common code styling
Hi
Is there any timeline for version 2.0.0 release?
Thanks
Ian Lim
Hi!
Is that possible to use nested queries in NativeCriteria? Tried to find this issue in your library but failed :(
edit: Somehow missed addSubqueryProjection method but failed to find how to remove the task not to close it.
Check is there easy possibility to add adapter which allows use the spring row mapper with native criteria
Hi
I'm not sure how to use NativeCriteria to form the FROM clause for the sql statement below:
SELECT
productID,
productName,
categoryName,
companyName AS supplier
FROM
products
INNER JOIN
categories ON categories.categoryID = products.categoryID
INNER JOIN
suppliers ON suppliers.supplierID = products.supplierID
Is there a test case or something which I can refer to ?
Thanks
Upgrade hibernate version and other dependencies to the newest available on maven central
ublic class NativeILikeExp implements NativeExp {
ββββprivate String columnName;
ββββprivate String varName;
ββββprivate String value;
ββββ/**
ββββ * @param columnName the column name
ββββ * @param valueββββββthe value
ββββ */
ββββpublic NativeILikeExp(String columnName, String value) {
ββββββββif (Strings.isBlank(columnName))
ββββββββββββthrow new IllegalStateException("columnName is null!");
ββββββββif (Strings.isBlank(value))
ββββββββββββthrow new IllegalStateException("value is null!");
ββββββββthis.columnName = columnName;
ββββββββthis.value = value;
ββββ}
ββββ@OverRide
ββββpublic String toSQL() {
ββββββββvarName = VarGenerator.gen(columnName).toLowerCase();
ββββββββreturn columnName + " ILIKE :" + varName;
ββββ}
ββββ@OverRide
ββββpublic void setValues(NativeQuery query) {
ββββββββquery.setString(varName, value);
ββββ}
}
There is a bug on the CriteriaResultImpl#getBoolean in case of the situation when db value is instance of Boolean. There should be additional checking whether value is instance of Boolean (not only the integer and String).
Hi - sorry to log this as an issue, this is just a question. In the README it says "without any other generated classed based on database schema". Do you mean that it does not require JPA classes or hibernate.cfg.xml
? I am looking for something like that.
Hi,
is there a way to use UNION or UNION ALL between two NativeQueries? I have looked on the source code and didn't found.
Thank you!
Remove the code with deprecated API of 1.X and use the correct methods from 2.X
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.