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:
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);
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: November 28, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles