What is @javax.persistence.Entity annotation?
-
I'm playing around with the Play! framework. I'm a beginner programmer and this is my first exposure to JPA. I'm getting an error because the "The JPA context is not initialized. JPA Entity Manager automatically start when one or more classes annotated with the @javax.persistence.Entity annotation are found in the application." I have @Entity listed before my class constructor and I thought that was enough. Thanks.
-
Answer:
The @Entity annotation is used to indicate that a class is persistent. In the Play! Framework you also have to extend from Model or GenericModel. The only difference between the two is that Model auto-generates a Long id to use as a primary key. Here's a basic example : import javax.persistence.*; import play.db.jpa.*; @Entity public class SomeModel extends Model { public SomeModel() { } } You said you put @Entity before the constructor, so I guess that's the cause of your error. Also make sure you extend Model or GenericModel.
Maarten Claes at Quora Visit the source
Related Q & A:
- How to translate high level entity relationship into schema?Best solution by Database Administrators
- how to fetch a value from persistence.xml to build.properties?Best solution by Stack Overflow
- How to convert an entity to Json?Best solution by Stack Overflow
- How to make Entity Framework migrations work?Best solution by Stack Overflow
- What are different types of Entities in Entity Framework?Best solution by entityframeworktutorial.net
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.