Installing/updating EclipseLink in Eclipse Dali - java

I'm currently using Eclipse Dali with EclipseLink 2.5.2.
Now I want to change to version EclipseLink 2.7.5, but I'm unable to find out how to setup Dali for new EclipseLink versions.
The JPA project dialog only shows EclipseLink 2.5.2 as a possible choice for the platform:
So I guess, I must download and install a new persistence platform so I'm able to select EclipseLink 2.7.5 from this dialog? Note that I already downloaded the zip archive for EclipseLink 2.7.5 - is it perhaps somehow possible to point Dali to this archive? Or is it necessary to manually remove EclipseLink 2.5.2 from the project's classpath and instead add the corresponding jar files for EclipseLink 2.7.5?
I'm sure that I'm missing something very obvious here since updating the persistence platform is certainly a common and easily done task... any help appriciated.

I was able to update to EclipseLink 2.7.5 by manually adding a new user library and then selecting this library in the JPA project dialog:
In the user library I simply added all jar files of EclipseLink 2.7.5 in the EclipseLink jlib folder.
Note that the folder of the library must not be a subfolder of the Eclipse project folder, otherwise Eclipse Dali will complain with the following error message (see this question):
The class 'javax.persistence.Convert' is required to be in the
selected libraries
Note also that for some reason it was necessary to move the EclipseLink 2.7.5 user library to the top of the dependency list in the Eclipse Run Configurations dialog.
I will happily accept any other answer that provides a more convenient way of updating EclipseLink.

Related

Where is the "Reverse Engineering" feature in Hibernate5?

I'm upgrading an old project from hibernate3 to hibernate5. The project has a dependency on hbm2java (the so-called reverse engineering tool). In the old project this was executed with mvn hibernate3:hbm2java.
Unfortunately, hbm2java is nowhere to be found in Hibernate5 - not in the code, not in the documentation.
What is the Hibernate5 equivalent of the old hbm2java? Or in case it's no longer supported, what's the closest alternative? I'm willing to get out of Hibernate entirely, if that's what it takes to get out of Hibernate 3.
The latest version of the hibernate-maven-plugin is 4.3.1.
You would get out of hibernate 3 by using hibernate 4.3.1 naturally.
It looks like the hbm2java task exists in the sources of the latest hibernate release: https://github.com/hibernate/hibernate-tools/blob/master/main/src/java/org/hibernate/tool/ant/Hbm2JavaExporterTask.java. That is what your were looking for isn't it? So it should also be possible to build the hibernate5 github project in your local maven repo and then bind the dependencies in your projects pom.
At last add the appropriate task and goal in your execution section.
Suggestion#1:
You can use maven ant runner. It may help.
mvn antrun:run#hbm2java
If you have modified templates (see the documentation) then, in pom.xml, modify the hibernate tool tag to look like:
<hibernatetool templatepath="src/the/path/to/the/directory/containing/pojo/directory">
The above path must point to the parent of the directory named pojo, containing your templates.
Also, if you have a custom reverse engineering strategy class the, in pom.xml add this attribute to jdbcconfiguration tag.
reversestrategy="fully.qualified.name.CustomDelegatingReverseEngineeringStrategy"
Resource Link: Hibernate tools reverse engineering using Maven
I haven't checked it but you can try with this procedure using Hibernate 5.X version.
Suggestion#2:
This issue seems critical in Hibernate 5.x version. All recommendation is to use 4.3 version for reverse engineering instead of 5.x
Resource Link: https://stackoverflow.com/a/37577315
Step by step tutorial to use 4.3 instead of 5.1 with pictorial view is given here:
http://o7planning.org/en/10125/using-hibernate-tools-generate-entity-classes-from-tables
Some issues are given below:
Database case-sensitive issue
type mapping
table filtering
no <schema-selection> tag is specified
This issues is required to resolve by hand (it's just basic XML) or you can use the Hibernate plugins, which provides a specialized editor.
http://www.hibernate.org/30.html
For reverse engineering rule, you can go through this tutorial: Chapter 6. Controlling reverse engineering

Java import from root of jar

I've used a 17 version of Guava for my library project and extracted it into the jar. Other project uses my library but it also has a much older version of Guava. When I try to run application, it ignores new Guava and causes errors like
java.lang.NoSuchMethodError: com.google.common.cache.CacheBuilder.maximumSize(J)Lcom/google/common/cache/CacheBuilder;
How to force my project to use a new Guava and application to use an old?
I am assuming that your project and applications are distinct entities.Also, by Project I assume that you are referring to an Eclipse/IntelliJ/Netbeans project
You would need to set the correct classpaths for the Project and your application separately.
If you are using the IDE to debug your project, your project would need to include the new JAR that you have downloaded. Each IDE has it's own mechanism for adding dependencies to the Project's classpath and hence you would want to refer to the documentation related to that IDE.
For your application you can launch it as java MyApp -cp "path to the old JAR". If you are packaging your application as a JAR, make sure you are packaging the older version of Guava.
Hope this helps.
Edit based on the discussion with the owner of the question
The query here is similar to this SO query. The right way to hence resolve this issue would be either install a Custom ClassLoader or use OSGi

Missing library for JSON and RESTful in Glassfish

After re-installed Netbeans 7.4 with a fresh Glassfish 4.0, I got missing and conflicting libraries. I am using Jackson library for working with JSON and I need Jersey (from what I remember) to work with RESTful (client).
If I include the Jersey 2.0 (JAX-RS RI) library in Netbeans I get a conflict with the default JPA persistence library (CascadeType and TypedQuery). But it includes JsonNode and the ObjectMapper classes.
These are the classes that causes my problem;
org.codehaus.jackson.JsonNode;
org.codehaus.jackson.map.ObjectMapper;
I also noticed that I can set the full JEE 7 profile (only web) in the project settings for Netbeans. I think this was available before in prevous versions of Netbeans.
What libraries (version) do I need to include (I don't use Maven) to solve my JSON/RESTful problem?
Glassfish already has JAX-RS libraries, so you don't need to add any JARs to your project except the Glassfish Runtime Libraries.
In Eclipse, check if you configured the Glassfish Runtime Library and if your project is assigned to use it. Also, check if you activated the Project Facet of JAX-RS. All this can be done on Properties menu of the project.
Instead of including the default Jersey 2.0 (JAX-RS RI) library in Netbeans, which causing the conflict with the JPA persistence library. I've downloaded and included these specific libraries to handle the JSON parsing and mapping;
jackson-core-asl-1.9.2
jackson-mapper-asl-1.9.2
I've downloaded the libs from The Central Repository

Hibernate Classes Not Importing with Eclipse Juno and GWT: LockMode, SessionFactory, Criterion

Environment
Ubuntu 12.04 LTS
Eclipse Juno 4.2 Build id: 20120614-1722
GWT SDK - 2.4.0
App Engine SDK - 1.7.2
Hibernate Version 3.5
JRE: java-7-openjdk-amd64
In reference to #mael comment, Hibernate Tools was installed from the following Eclipse repo:
http://download.jboss.org/jbosstools/updates/stable/indigo/
Problem
The project is a GWT Web Application that uses Hibernate as the entity/persistence manager. I have successfully configured Hibernate to connect to the database, and it pulls in all the tables and associated columns I am interested in. I use Hibernate to reverse engineer the entity/persistence classes; it runs successfully, but I get the import errors in the newly generated classes:
The import org.hibernate.LockMode cannot be resolved.
The import org.hibernate.SessionFactory cannot be resolved.
The import org.hibernate.criterion.Example cannot be resolved.
Research/Troubleshooting
There was similar problem I found here. I performed the search for the aforementioned classes, and did not find them. I then readded java-7-openjdk-amd64 JRE under Windows > Preferences > Installed JREs. This did not resolve the problem.
Also, there does not seem to be very much out there for this problem. So I am assuming there is something I have not understood in the setup of Hibernate and reverse engineering.
Another Similar Problem - Same Solution
Update: Solution
Following #mael's solution, I confirmed that Hibernate Tools does not automatically include the Hibernate jar files required for the auto-generated entity/persistence classes.
Downloaded the Hibernate4 jar files from the following location.
Extracted files to the Eclipse workspace.
In Eclipse, right-click on {Project} and go to Build Path > Configure Build Path... > Java Build Path.
Click on the Libraries tab.
Click on Add External JARs...
Go to directory where Hibernate4 JAR files were extracted, and follow the path to lib > required.
Select all JAR files in the folder and confirm.
You may want to check your eclipse Build Path.
Right-click your project and navigate Build Path>Configure Build Path and in the tab libraries look for the Hibernate library, if you do not see it then download the jars manually or optionally use maven or ant to do this.
I don't remember if Hibernate Tools incorporates the Hibernate jars in the eclipse set of libraries. But if it doesnt, it should I guess.

Hibernate Setup

I always used Hibernate annotations in my old job, but since all our projects were already set up, I never really learned the mechanism behind it.
Could someone please give me a brief outline of how to set everything up, just to get me started?
I am developing in Java using Maven and Oracle 10g Express Edition. My IDE is Eclipse.
I'd recommend starting with the Hibernate tutorial. Basically, you'll need to create a Hibernate configuration file on your classpath (dropping it in src/main/resources works with the default Maven project layout) and then start annotating your data objects. There's a tutorial for Hibernate with XML configuration as well.
The (non-Maven) steps to build a Hibernate project in Eclipse would be:
Step 1: Add the required JARs to setup Hibernate project
Step 2: Add the JARs to the lib folder of your project
Step 3: Additionally, I would suggest you to explore the Hibernate directory structure since you are using it for the first time.
If you need more assistance, I wrote a post on my site http://myjavatrainer.com/setup-hibernate-project/
Hope it will be helpful to you.
Maven is build tool for your projects. Maven is a build tool by Apache, it will help to manage the dependencies better. You will have to install Maven separately and set it up. Read its documentation full and get it setup. Instead of creating a normal Java app or a web app in Eclipse, you will be creating a Maven project.
MAKE SURE YOU ADD A JAR FOR DRIVER CONNECTOR for the type of database you are planning to use through Hibernate.

Categories

Resources