Web servers - CHAPTER 9 n SEARCHES AND QUERIES 209 n

CHAPTER 9 n SEARCHES AND QUERIES 209 n SEARCHES AND QUERIES 209 simple HQL named query, and one simple SQL query that does the same thing, we have the Hibernate mapping file shown in Listing 9-4: Product.hbm.xml. Listing 9-4. Product.hbm.xml
25.0]]> 25.0]]>
Notice that we embedded the SQL and HQL queries in CDATA regions. This protects our SQL queries from interfering with the XML parser we don t have to worry about special characters breaking the XML. For the native SQL query, we also had to specify a return type, so Hibernate knows what type of result data to expect from the database. When you use HQL, Hibernate handles that mapping behind the scenes, because it knows which objects went in. With SQL, you have to specify the return types yourself. In this case, we used the XML element to define our return type as a column named price, with a type of double. Hibernate converts the JDBC result set into an array of objects, just like the previous HQL query. Functionally, they are identical. We discuss native SQL in more detail in the next section of the chapter. You may also specify the flush mode, whether the query is cacheable, the cache region, the fetch size, and the timeout for the HQL and SQL queries. For the SQL query, you may additionally specify whether the SQL query is callable.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply