Java Reference
In-Depth Information
//Downcasting
CriteriaQuery<Person> cqp =
cb.createQuery(Person.class);
Root<Person> person = cqp.from(Person.class);
cqp.select(person).where(cb.equal(person.type(),Appuser.class),cb.equal(cb.treat(person,
Appuser.class).get("userLogin"),"adwiner"));
TypedQuery<Person> tqp = em.createQuery(cqp);
System.out.println("result : " +
tqp.getResultList());
DDL generation
Since the previous version of the JPA Specification, it is possible to create or drop
and create tables. However, the support for this feature was not required and the
specification document made us understand that the use of this feature could reduce
application portability. Well, with JPA 2.1, the DDL ( Data Definition Language ) gen-
eration was not only standardized but has been expanded and is now required.
In this case, new properties have been added. You have for example the following
properties:
javax.persistence.schema-generation.database.action : This
defines the action (none, create, drop-and-create, or drop) that should be
taken by the provider.
javax.persistence.schema-generation.create-source : This
defines the source (entities, specific scripts, or both) to be used by the pro-
vider in the case of a DDL generation.
javax.persistence.schema-generation.drop-source : This
defines the source (entities, specific scripts, or both) to be used by the pro-
vider in the case of drop table.
javax.persistence.schema-generation.connection : This defines
the JDBC connection parameters to use for the DDL schema generation in
order to take into account the management of privileges in some databases
such as Oracle. This parameter was thought of for Java EE environments.
The following persistence unit provides an example of configuration to generate
tables at the creation of EntityManagerFactory . This generation will be based
on entities' information (metadata) and it will take place if and only if the tables to be
Search WWH ::




Custom Search