Object/relational mapping metadata @org.hibernate.annotations.NamedQueries({ @org.hibernate.annotations.NamedQuery( name = “findItemsOrderByPrice”, (Tomcat web server)
Object/relational mapping metadata @org.hibernate.annotations.NamedQueries({ @org.hibernate.annotations.NamedQuery( name = “findItemsOrderByPrice”, query = “select i from Item i order by i.initialPrice)” ) }) package auction.persistence.types; This example of a package metadata file, in the package auction.persistence.types, declares two Hibernate type converters. We ll discuss the Hibernate type system in chapter 5, section 5.2, The Hibernate type system. You can now refer to the user-defined types in class mappings by their names. The same mechanism can be used to externalize queries and to define global identifier generators (not shown in the last example). There is a reason the previous code example only includes annotations from the Hibernate package and no Java Persistence annotations. One of the (lastminute) changes made to the JPA specification was the removal of package visibility of JPA annotations. As a result, no Java Persistence annotations can be placed in a package-info.java file. If you need portable global Java Persistence metadata, put it in an orm.xml file. Note that you have to name a package that contains a metadata file in your Hibernate or JPA persistence unit configuration if you aren t using automatic detection see chapter 2, section 2.2.1, Using Hibernate Annotations. Global annotations (Hibernate and JPA) can also be placed in the source code of a particular class, right after the import section. The syntax for the annotations is the same as in the package-info.java file, so we won t repeat it here. You now know how to write local and global mapping metadata. Another issue in large-scale applications is the portability of metadata. Using placeholders In any larger Hibernate application, you ll face the problem of native code in your mapping metadata code that effectively binds your mapping to a particular database product. For example, SQL statements, such as in formula, constraint, or filter mappings, aren t parsed by Hibernate but are passed directly through to the database management system. The advantage is flexibility you can call any native SQL function or keyword your database system supports. The disadvantage of putting native SQL in your mapping metadata is lost database portability, because your mappings, and hence your application, will work only for a particular DBMS (or even DBMS version).
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.