Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jee Jee7 Jpa Persistent Fields and Properties in Entity Classes

Related Tutorials


 
 

Share on Google+Share on Google+

Persistent Fields and Properties in Entity Classes

Advertisement
Learn what is Persistent Fields and Properties in Entity Classes

In this tutorial we will understand about the Persistent Fields and Properties in Entity Classes. Here we will learn about the field types supported in the JPA.

As explained in the earlier sections the Entity is managed by the EntityManager and it provides the API's for accessing the entities. You can load an entity and then access its state through variables or properties. In JPA fields and properties must confirms to the types as described in the JPA specification.

Following Java Language types of fields and properties are supported:

  • Java primitive types
  •  java.lang.String
  •  Other serializable types, including:
    - Wrappers of Java primitive types
    - java.math.BigInteger
    - java.math.BigDecimal
    - java.util.Date
    - java.util.Calendar
    - java.sql.Date
    - java.sql.Time
    - java.sql.TimeStamp
    - User-defined serializable types
    - byte[]
    - Byte[]
    - char[]
    - Character[]
  •  Enumerated types
  •  Other entities and/or collections of entities
  •  Embeddable classes

The JPA specification allows the entities to use persistent fields, persistent properties, or a combination of both. You can use the mapping annotations to properly specify the meta-data to the JPA runtime. The Java style getters and setters methods are used to access the properties/entities.

Finding Entities Using the EntityManager

You can find an entity using the the find method of EntityManager. Here is an example:

Product prodObj = em.find(Product.class,2);

Read more JPA 2.1 tutorials.

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 28, 2013

Related Tutorials

Discuss: Persistent Fields and Properties in Entity Classes  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com