Does JBoss7 allow Hibernate 3 xml configuration? - java

First I excuse if this is a stupid question.
I am trying to deploy my spring application into JBoss 7. Hibernate entities are configured with xml. That means PojoClass.hbm.xml and not annotated.
What I want know simply is, do JBoss 7 or 8 version support only Hibernate (version 3) mapping Annotations (POJO class mappings to database tables)? and no xml configurations ? If it is possible, would you let me have any guidance resource URL please ?

Check out this guide exampling how you can switch from Hibernate 4 to Hibernate 3.
Once you enable Hibernate 3, you only need to set the JBoss Transaction Manager resolving settings.

Related

Websphere + Spring: javax.transaction.Transactional

Using Spring within Websphere, when using the javax.transaction.Transactional. Running the code locally or within Tomcat works as intended but while running within Websphere, it appears that the javax.transaction.Transactional annotation is not resulting in a Transaction that includes the JPA-EntityManager. Replacing the javax.transaction.Transactional annotation with the Spring version of Transactional solves this issue.
We would like to know what is required to fix this issue. I found this Stackoverflow-issue: spring-jta-transaction-with-jpa-and-jndi-datasource-for-websphere which links to the Article: 0609_alcott-pdf.pdf
The advise given is to configure Spring to use the WebSphereUowTransactionManager as transaction manager.
The stackoverflow answer is from 2012. But since we are running a farely old WebSphere 7 version, it might sill be relevant to us.
Does anyone experienced the similar or a related problem?
Update
The following dependencies are used:
spring-core: 4.3.9
hibernate.core: 4.2.15.Final
spring-boot starter: 1.5.4.RELEASE

how to switch spring 4 + Hibernate with mongoDB project to MySQL?

I searching too much for my question in www.stackoverflow.com, but nothing helps me.so I have to post my question.
I have completed my project in spring 4 + Hibernate with MongoDB. now client requirement is MySQL. so I have to switch that project in Hibernate with MySQL.
I have tried to write code in the project. but it shows to much error in session as NullPointerException and another about my service and repository related.
so can you suggest any demo for a Hibernate with MySQL configuration in spring MVC 4.? and yes which configuration is good? XML based or java class based?
Please follow the link, it would help you to get start with Spring MVC + Hibernate (MySQL).
https://examples.javacodegeeks.com/enterprise-java/spring/mvc/spring-mvc-hibernate-tutorial/
About configuration: I personally prefer Java based configuration (not XML)
For xml configuration please have a look at:
http://www.codejava.net/frameworks/spring/spring-4-and-hibernate-4-integration-tutorial-part-1-xml-configuration
You should use Spring Boot instead of Spring MVC 4. Spring Boot will help you a lot as not too many configuration. You can easily switch to this without too much changes. No persisting of entity need to write as you can use Spring Data JPA for that.
You can following Spring Boot + Hibernate example by StartWithJava.
http://www.startwithjava.com/spring-boot-web-application-using-themeleaf/

Google Cloud Dataflow application that uses JPA 2 and Hibernate won't run with BlockingDataflowPipelineRunner. Fails to find persistence.xml

I have a Google Cloud Dataflow application that as part of a transform records some information to a MySQL database through JPA 2 and Hibernate. When running this application with the DirectPipelineRunner it locates the persistence.xml and runs fine.
However, when I try to make use of the BlockingDataflowPipelineRunner the persistence context won't initialize because it can't find the persistence.xml. Maybe it can't be loaded from the CLASSPATH? The message being that the only persistence unit named in the persistence.xml isn't found.
Has anyone successfully used JPA 2 and Hibernate with a Dataflow application? If so, what hoops did you have to jump through to get it working when using the BlockingDataflowPipelineRunner?
Hibernate by default looks for the persistence.xml file in potentially many locations. You may want to confirm that the jars that get uploaded contain META-INF/persistence.xml.
If you add the flag
--workerLogLevelOverrides=org.hibernate#TRACE
, that should give you much more detailed output related to Hibernate (you may need to configure JBoss logging to go to SLF4J or JUL to get the Hibernate logging to appear, docs.jboss.org/hibernate/orm/4.3/topical/html/logging/…).

Hibernate Validator 5 version compatibility with Hibernate 3.5

Is it safe to use the Hibernate Validator 5.0.1 with Hibernate 3.5.4? From what I've read it should not be a problem and I'm not running into any errors so far (i.e. application compiles, runs and tests pass), but I'm not sure if they fit well together.
Related Hibernate & JPA libs (inside /WEB-INF/libs):
hibernate3.jar
hibernate-annotations-3.5.4-Final.jar
hibernate-commons-annotations-3.2.0.Final.jar
hibernate-core-3.5.4-Final.jar
hibernate-entitymanager-3.5.4-Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-validator-5.0.1.Final.jar
hibernate-validator-annotation-processor-5.0.1.Final.jar
validation-api-1.1.0.Final.jar
FYI:
Tomcat 7.0.39
Spring 3.0.3
PostgreSQL 9.2
Flyway 2.1.1
BoneCP 0.7.1
You should be fine with using Bean Validation 1.1/Hibernate Validator 5.0.1; Hibernate ORM depends on the Bean Validation API only, and BV 1.1 is compatible with BV 1.0.
I recommend to check the Hibernate Validator migration guide to see whether any of the issues listed there might affect you (for instances changes around logging and the usage of Java 6).

Should you default to the JPA provider of the application server?

I have a 100% JPA2 compliant application which needs to be portable to many application servers. Being JPA compliant (theoretically) means we can switch JPA providers via configuration (e.g. without changing source code) -- (right???).
When running within a servlet container (e.g. Tomcat, Jetty) the application is configured to run with Hibernate. We choose Hibernate over TopLink and Eclipselink for its maturity and performance. So far this works.
However, when running within a Java EE application server, should we default to the JPA provider therein, or stick with Hibernate?
I know within JBoss, the provider is Hibernate so it probably doesn't matter. However, I think the provider within WebLogic is Eclipselink. I have no idea what the provider WebSphere or Glassfish use, but I have seen detailed instructions on how to use Hibernate as the provider within those application servers.
I guess another way to ask the question is what would we be missing by using Hibernate in these application servers?
I have a 100% JPA2 compliant application which needs to be portable to many application servers. Being JPA compliant (...) means we can switch JPA providers via configuration (...)
Yes.
(...) However, when running within a Java EE application server, should we default to the JPA provider therein, or stick with Hibernate?
Well, if you deploy on a Java EE 6 server, this doesn't really matter. It's not clear who is going to run the application and you can maybe make recommendations but the runtime is actually "not your business" :) Also note that you may not benefit from support if you don't use the default provider (if this matters).
I know within JBoss, the provider is Hibernate so it probably doesn't matter. However, I think the provider within WebLogic is Eclipselink. I have no idea what the provider WebSphere or Glassfish use, but I have seen detailed instructions on how to use Hibernate as the provider within those application servers.
First of all, keep in mind that JPA 2.0 is part of Java EE 6 and that GlassFish v3 is the only one Java EE 6 container at this time. WebLogic and WebSphere are Java EE 5 server, they may not support JPA 2.0.
Now, regarding the default providers:
GlassFish v3 uses EclipseLink 2.0 as default provider but can be configured to use Hibernate 3.5 (through an add-on).
In Weblogic 10.3.2, the default JPA provider is OpenJPA/Kodo and EclipseLink 1.2 is available as a WLS module. In WLS 10.3.3 (not released yet), EclipseLink 2.0 will be available as a WLS module, the default being still OpenJPA/Kodo. But, the container JPA API will still be JPA 1.0! It seems possible to package a JPA 2.0 provider inside your application. See this thread and this page. But this is not officially supported and doing this same thing with Hibernate 3.5 might be another story.
In WebSphere 6 and 7, the default provider is OpenJPA. This link will give you some details about the way to change the default provider (and the consequences). But I can't tell you more.
I guess another way to ask the question is what would we be missing by using Hibernate in these application servers?
As I mentioned, this may not be supported by the vendor. Additionally, if you want to maximize portability and plan to deploy your application in a near future, going for JPA 2.0 is maybe not a wise choice (or too optimistic if you prefer).
I don't see what you will be missing, unless you're using implementation specific API in your JPA code. I.e. do not import org.hibernate anywhere in your JPA code, but just write it against the JPA API.

Categories

Resources