Query regarding Persistance Framework - java

I am a bit confused about using the jars to handle database part in Java development:
In my current project, these three jars are being used:
1) ejb3-persistance.jar (#Entiry #Table annotations are taken from this)
2) hibernate3.jar
3) spring-core.jar (JdbcDaoSupport is used from this jar)
Please explain me the details usage of including these jars. (I want to understand the persistance framework in detail).
Please help.

Those annotations are "standard" ejb3 annotations.
Hibernate is the specific ORM being used (it will leverage the "standard" annotations)
Spring is providing the JDBC connection that Hibernate is using.
For more details about what each of these three component frameworks does, I would suggest you visit their respective projects and read their documentation. It's too much for SO.

Related

Reverse engineering a java rest based services from database

Problem
I have a relational database schema (in Oracle, but could be in Mysql or Postgres) and I need to expose basic CRUD operations on tables with REST services, all withtout a line of code from a developer.
Constraint of my problems are: java 6/7 only (not scala, groovy, etc..), maven based solution, possibly framework agnostic (could be separated from Spring, for example).
A mandatory requirement is all of this stuff must run on Tomcat (6 or 7).
Bonus: junit of similar automated test on CRUD operation using Mocks and a webpage to test services
Possible solutions
I have already investigated into Spring Roo, not finding a decent configuration or tutorial for my problem.
I have tried to reverse-engineering database using jboss hibernate tools and fits well. Using this tool I can manage to do a maven module (a persistence jar) with all entities mapped.
But I also need a code organization using DAO pattern (to handle entities) and a service layer (to setup REST services).. and this seems to be tricky.
Edit: I've found this solution, using maven hbm2dao, I'm on right path?
Thanks for your time!
p.s: I've found this solution, seems good, but is made with python :(

Hibernate - difference between annotations and commons-annotations?

To keep it short and sweet:
There is hibernate-commons-annotations 4.1.0-Final and hibernate-annotations 3.5.6-Final.
I'm a nub, what's the difference between them, and do I need them both?
Trying to "avoid" JPA and by that I mean using the JPA 2.0 standards embedded within Hibernate.
Thanks!
Previously, hibernate-annotations was released and versioned from hibernate core. But from version 3.5 and up it is included with hibernate core. And for some reason it was still released from 3.5.0 to 3.5.6 but you do not need it anymore.
And coming to hibernate-commons-annotations, it is a utility project used by annotations based hibernate sub-projects. It is used by other hibernate projects like hibernate-search and thus is maintained as a separate project and it is a compile time dependency for hibernate-core v3.6.0 and up.
Source 1
Source 2
Hibernate Commons Annotations is "Utility project for annotation handling", as said for example here. It does not contain such API that normal user of Hibernate should use.
Hibernate annotations contained persistence mapping annotations and related code. Nowadays it is merged to Hibernate core.
If you really want to avoid JPA (1/2) that is easily done by not using classes from javax.persistence package or from its subpackages. If you want opposite, use javax.persistence and avoid org.hibernate packages where possible.
Good guide to get started with Hibernate can be found from http://docs.jboss.org/hibernate/orm/4.1/quickstart/en-US/html_single/. It also tells which libraries are needed always and which ones are optional.
Reference documentation contains plenty of advices about using JPA instead of deprecated legacy Hibernate annotations.

Hibernate integration on a Spring web application

I have been following this tutorial on the Springsource website in order to have basic knowledge of Spring. Everything went good.
Now, I would like to integrate Hibernate to this little application I wrote following this tutorial. I found documentation on different websites (including hibernate's website) but I still have a few questions before starting.
I read some stuff about JPA and I can use it as an abstraction layer on top of hibernate but I don't really understand what for.
In addition, I read somewhere that there is two ways to use hibernate, the first one is annotations and the second one is using javax.persistance, I am right?
Is there some recent documentation about how to use hibernate in an existing spring web application, as well as the different ways to implement it?
JPA is a specification, hibernate can be considered as a implementation of the JPA spec.
You can use either annotation for mapping file with hibernate.
The following tutorials are better:
Hibernate Tutorial Vaannila
Hibernate Tutorial Mkyong
JPA is a standard, Hibernate is an implementation, but has other/additional functionality.
The Spring Reference manual's section on ORM integration covers Hibernate. There are also scores of tutorials and demos, like here, but there are a bunch of other ones, and more recent ones.

Hibernate implementation of JPA

I'm wanting using JPA in ear project. Development project must be started ASAP so I have not a lot of time to research and investigate. Could you say please JPA API is restricted functionality of Hibernate or no. At this moment I'm using Hibernate directly. For example in future I'm planing to use hibernate-search and maybe hibernare-validate and -shard. Can I be sure that in future I will not have problem with using this.
And one more example - can I use HAR archive and JPA together.
Why JPA? For project will available RESTful service (jersey or resteassy implementation). And as I looked in much case using JPA for this. I'm a newbie in this so it's only my IMHO. May be i mistakes.
Thanks a lot.
Best regards
Artem
JPA is a subset of hibernate, but you're not limited to it. If you need a hibernate specific feature, you can generally use it at the cost of being tied to hibernate. For example, we've mixed in hibernate annotations with JPA ones, including the validater ones, without trouble.
JPA in theory lets you change the persistance provider later.
Sticking to only JPA compatible configuration can cause more trouble that is solved by the dubious promise of seamlessly swapping providers however.

eclipse default jpa implementation library where to download?

In eclipse, the "default implementation library" what jars files do I need to include if I do not want to use server runtime?
I'm refering to this tutorial http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jpt.doc.user/task_create_new_project.htm
Follow Using TopLink JPA with Dali to get started with the Toplink Essentials (JPA reference implementation). To get the mentioned jars (toplink-essentials.jar and toplink-essentials-agent.jar), download them from there or, if you use Maven, from the Java.Net Maven Repository.
PS: Please note that after 2.0-b36, the toplink-essentials-agent.jar file is no longer needed as the agent facility is now integrated into toplink-essentials.jar. So you can do like below.
$ java -javaagent:toplink-essentials.jar client.Client
Depends on what implementation you want to use. There are currently three most popular implementations: Hibernate, TopLink and EclipseLink.
I know about hibernate that it's README file explains what jars are mandatory for what functions. If you use JPA you must have some sort of EntityManager (hibernate can be used without EntityManager too), so you need all the dependencies of it.
To download hibernate JPA implementation use this link (look for hibernate-entitymanager). You need hibernate core, annotations and entity manager for JPA. If you use all the jars in those three packages you should be ok. But I strongly suggest you to read the README files.

Categories

Resources