简体   繁体   中英

How to migrate spring annotation-based Hibernate code to Java EE

First of all: here is my code: https://github.com/s1ddok/todosapp

I'm learning java technologies. I forked a demo project on github and for now my goal is to add login (user specific todos) and hibernate mysql stuff. I successfully done it for -spring version. Now I want to do the same stuff for java ee.

How do I migrate annotation based hibernate code (Entities and config) to java ee? Is it possible to simply reuse them? I heard that you have to use xml config with Java EE, is it true?

My requirement is to use same front-end (backbone) and same database for both -spring and -javaee . This is my goal. I have to implement same-functionality REST service with spring and javaee.

I'm completely stuck with that.

With JavaEE you do not have to use much XML configs (in comparison with the old J2EE), but you can do most things with annotations.

Regarding database access you can still use Hibernate ( JPA ), since JPA is part of the JavaEE spec. The Json annotations like com.fasterxml.jackson.annotation.JsonIdentityInfo are not part of JavaEE spec (yet), so you might have to use JAXB instead.

Regarding REST you want to have a look at JAX-RS . The annotations are different in comparison to Spring ( @ApplicationPath, @Path, @GET, ... ), but you should be able to achieve the same result for you application.

For security (login) you have to look at application server specific options, since this be will standarized only in JavaEE 8 (JSR 375).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM