Typesafe queries for TopLink - toplink

Is there any other way to do typesafe queries with TopLink than through the JPA 2.0 Criteria API?
From a sales meeting I got the impression that this is possible through a proprietary part in TopLink, but I couldn't find any related documentation.

No, JPA 2.0 is the only way.
TopLink does also provide Expression objects, but they are not typed.
If you just want dynamic queries, you can use Expressions instead of Criteria.

hi you can use alternative library like query dsl or object query

Related

Using Spring JPA Specification with OData Queries

so i have a spring boot application and my data source is MySQL via JPA. I am trying to introduce Odata queries to my API's and then fetch data based on those odata params. I was wondering if there are any utils or external libraries i can use to parse the odata query then construct the JPA Specification. I have looked into olingo but im not sure if it is exactly what i am looking for. I was thinking of parsing the query text, and constructing the jpa specifications manually(maybe use reflection is necessary), but if anyone has any tips or advice on how to better approach this it would be much appreciated!!
I was thinking of doing something similar to this but with odata instead. Only issue i see is making this dynamic enough to handle every complex odata query coming in.
https://www.baeldung.com/rest-api-search-language-spring-data-specifications

What is the best way to use Spring and ElasticSearch?

I have to implement some application by using springframework.
All i have to do is just select from repository (no RDBMS, maybe lucene or elastic search core) and Display some view pages for customers. that is not save or update but read.
What is the best way to select for repositories in spring framework ?
You can use spring-data-elasticsearch which is the Spring Data implementation for ElasticSearch.
In order to get started, you may like to refer to https://www.mkyong.com/spring-boot/spring-boot-spring-data-elasticsearch-example/ which explains the integration with an example. Although it is a bit old but provide you with enough information to get it working.

Querydsl vs ES Querydsl

I have been asked to look into Querydsl. So, I've been searching on line and there appears to be two of them: one sponsored by Mysema and the other created by Elastic Search. I'm a bit confused about the differences in the functionality. Is Elastic Search's Querydsl an expansion on Querydsl? Can anyone point me to or provide an example that compares the uses of the two?
So far this is what I know:
Querydsl
Java Framework
Supports JPA, JDO, SQL, Java collections, RDF, Lucene, Hibernate Search, and MongoDB
Generates type-safe queries with a syntax is similar to SQL
ES Querydsl
Based on JSON
Similar to REST Query DSL
Query language for full-text and structured search
I have been using QueryDsl (Java framework) for a while. As far as I know, they are two different things.
The QueryDSL is a framework to write type-safe queries in Java.
While the ES Query DSL is a language based on JSON to write queries in ES.
Assuming that you are going with version 2.x it's recommended that you just use a plain http client and use the ES query dsl, as ES usually yanks out classes between versions.

How to choose that which ORM would be feasible for or Application? e.g if we are using Linq then why not hibernate

How to choose that which ORM would be feasible for a web Application? e.g if we are using Linq then why not nhibernate? and Which one is better and why
Every ORM that claims linq support, supports linq to a degree, however the completeness of the implementations vary greatly, sometimes because of the way the ORM is implemented, sometimes because of the quality of the Linq implementation.
Even the Linq implementations between Linq to Sql and Entity Framework v4 vary greatly, if you then look at NHibernate's or LlblGenPro's implementations you will find there are queries that are possible in sql that each doesn't support in the same way, if at all, or that the support with different levels of efficiency.
You really need to evaluate the particular ORM's Linq implementation against the type of data retrieval you tend/want to do.
I think a lot would depend on the application you are building.
On the other hand, NHibernate is very powerful and can be customized to do just about anything. We recently dumped our old ORM and moved to NHibernate because we just couldn't do what we needed to do without it.
You can use Linq with nHibernate. But take the most popular ORM. The one the most developers use.
It will be easier to find a developers to maintain and enhance the project and it will be easier to find solutions to your problems on Google.
I'm still using nHibernate but new versions of Entity Framework look promising.
I will switch when Entity Framework will become as powerful as nHibernate.

Hibernate with MongoDB

I'm looking for resources showing how to integrate MongoDB with Hibernate (preferably from within spring) so that I can switch between a RDBMS and a NoSql alternative: does anyone have experience doing this?
You can't easily do this. The point of Hibernate is to map Java Objects to a relational database. Although Hibernate abstracts a lot of details away you still need to understand how relational databases work with things such as foreign and primary keys, and the performance implications of queries you run. MongoDB requires an entire different way of designing your database focusing on objects instead of columns and tables. while you may be able to create a Hibernate dialect for MongoDB creating a design that would work on both a relational database and a NoSql database will give you a design that works poorly on both.
What about Hibernate OGM? It provides JPA for No-SQL databases.
Migration would be easier if you use Spring MongoTemplate (similar to HibernateTemplate). Among its features is support for JPA annotations (although, I'm not sure to what extent).
See more: http://www.springsource.org/spring-data/mongodb
You'll need the following:
Add spring-data-mongodb JAR to your project (available in maven
central).
Add mongo-java-driver JAR to your project (available in
maven central).
Use the provided MongoTemplate class in a similar
manner to HibernateTemplate. E.g.:
mongoTemplate.findById(id, MyClass.class);
mongoTemplate.insert(myObject);
Here's a concrete example with code: use-spring-and-hibernate-with-mongodb
If you are using Java then you can use Hibernate OGM it provides Java Persistence support for NoSQL databases.
For more details visit http://hibernate.org/ogm/
There is nice work done earlier as:
http://pragmaticintegrator.wordpress.com/2011/07/14/use-spring-and-hibernate-with-mongodb/
http://pragmaticintegrator.wordpress.com/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/#comments
refer to these links. it will be helpful to you.
There is also kundera, which uses JPA-annotations to read/write your object from/to a mongodb. If you ara familiar with hibernate, it should be quite straightformard to use.
I recently tried Morphia, which takes the same approach, but with its own annotations.
It works fine
May this blog helps: http://drorbr.blogspot.com/2010/02/migrating-springhibernate-application.html
Here Dror Bereznitsky describes nicely how to integrate a sping/hibernate based solution with mongodb.
For the sake of completeness, PlayORM also supports MongoDB now. PlayORM is an object NoSQL mapping solution so you can write POJO’s and let it deal with all the details of marshalling/unmarshalling to MongoDB. Visit its documentation here
I think Hibernate provides desired functionality. Take a look at this, found on their official website:
Mixing several NoSQL datastores in one application, e.g. use Neo4j for your friendship graph and MongoDB for your blog posts. Or mix NoSQL and relational databases.
reference
Well just to give you an example, I am doing somehting simmilar. In ColdFusion, Hibernate is integrated and in order to save your Hibernate Object, you hvae to do EntitySave(Obj). However what we have done is build the Orm object, and then use a mongoDB Coldfusion component and just save the object by going mongo.Save(obj,collectionName).

Resources