java - How to write DDL in the criteria API? -


consider code in how delete jpa entities? documentation here http://download.oracle.com/docs/cd/e17410_01/javaee/6/tutorial/doc/gjitv.html describes queries.

the documentation of criteria api describes queries because criteria api not made ddl operations. actually, i'd whole jpa api not made that.

and way, code of other question doesn't show ddl operations, it's shows bulk dml operations described in jpa 2.0 specification:

4.10 bulk update , delete operations

bulk update , delete operations apply entities of single entity class (together subclasses, if any). 1 entity abstract schema type may specified in or update clause.

the syntax of these operations follows:

update_statement ::= update_clause [where_clause] update_clause ::= update entity_name [[as] identification_variable]                      set update_item {, update_item}* update_item ::= [identification_variable.]{state_field | single_valued_object_field} =                      new_value new_value ::=        scalar_expression |        simple_entity_expression |        null  delete_statement ::= delete_clause [where_clause]  delete_clause ::= delete entity_name [[as] identification_variable] 

the syntax of clause described in section 4.5.

a delete operation applies entities of specified class , subclasses. not cascade related entities.

the new_value specified update operation must compatible in type field assigned.

bulk update maps directly database update operation, bypassing optimistic locking checks. portable applications must manually update value of version column, if desired, and/or manually validate value of version column.

the persistence context not synchronized result of bulk update or delete.

caution should used when executing bulk update or delete operations because may result in inconsistencies between database , entities in active persistence context. in general, bulk update , delete operations should performed within transaction in new persistence context or before fetching or accessing entities state might affected such operations.

examples:

delete customer c c.status = ‘inactive’  delete customer c c.status = ‘inactive’ , c.orders empty  update customer c set c.status = ‘outstanding’ c.balance < 10000 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -