CHAPTER 12 (Free web space) Modifying objects efficiently ownerFirstname, onwerLastname, ownerLogin,
CHAPTER 12 Modifying objects efficiently ownerFirstname, onwerLastname, ownerLogin, ownerEmailAddress, ownerHomeAddress) select c.type, c.number, c.expMonth, c.expYear, u.firstname, u.lastname, u.username, u.email, u.homeAddress from CreditCard c join c.user u where c.stolenOn is not null” ); int createdObjects = q.executeUpdate(); This operation does two things: First, the details of CreditCard records and the respective owner (a User) are selected. The result is then directly inserted into the table to which the StolenCreditCard class is mapped. Note the following: The properties that are the target of an INSERT … SELECT (in this case, the StolenCreditCard properties you list) have to be for a particular subclass, not an (abstract) superclass. Because StolenCreditCard isn t part of an inheritance hierarchy, this isn t an issue. The types returned by the SELECT must match the types required for the INSERT in this case, lots of string types and a component (the same type of component for selection and insertion). The database identifier for each StolenCreditCard object will be generated automatically by the identifier generator you map it with. Alternatively, you can add the identifier property to the list of inserted properties and supply a value through selection. Note that automatic generation of identifier values works only for identifier generators that operate directly inside the database, such as sequences or identity fields. If the generated objects are of a versioned class (with a version or timestamp property), a fresh version (zero, or timestamp of today) will also be generated. Alternatively, you can select a version (or timestamp) value and add the version (or timestamp) property to the list of inserted properties. Finally, note that INSERT … SELECT is available only with HQL; JPA QL doesn t standardize this kind of statement hence, your statement may not be portable. HQL and JPA QL bulk operations cover many situations in which you d usually resort to plain SQL. On the other hand, sometimes you can t exclude the application tier in a mass data operation.
You want to have a cheap webhost for your apache application, then check apache web hosting services.