<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Cheap Java Services With Tomcat, Jsp, Php, Mysql, J2Ee, Servlet, Struts &#038; Hibernate Hosting Support and Coldfusion Web Hosting</title>
	<link>http://j2ee.javaservletwebsitehosting.com</link>
	<description>Java quality service reviews blog</description>
	<pubDate>Tue, 10 Jun 2008 07:06:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>CHAPTER 15  (Web server iis) Advanced query options 15.1.3 Projection and</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-web-server-iis-advanced-query-options-1513-projection-and/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-web-server-iis-advanced-query-options-1513-projection-and/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 07:06:20 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-web-server-iis-advanced-query-options-1513-projection-and/</guid>
		<description><![CDATA[CHAPTER 15   Advanced query options   15.1.3 Projection and report queries  In HQL, JPA QL, and SQL, you write a SELECT clause to define the projection for  a particular query. The Criteria API also supports projection, of course  programmatically and not string-based. You can select exactly which objects or [...]]]></description>
			<content:encoded><![CDATA[<p>CHAPTER 15   Advanced query options   15.1.3 Projection and report queries  In HQL, JPA QL, and SQL, you write a SELECT clause to define the projection for  a particular query. The Criteria API also supports projection, of course  programmatically and not string-based. You can select exactly which objects or  properties of objects you need in the query result and how you possibly want to  aggregate and group results for a report.   Simple projection lists   The following criteria query returns only the identifier values of Item instances  which are still on auction:   session.createCriteria(Item.class)  .add( Restrictions.gt(&#8221;endDate&#8221;, new Date()) )  .setProjection( Projections.id() );   The setProjection() method on a Criteria accepts either a single projected  attribute, as in the previous example, or a list of several properties that are to be  included in the result:   session.createCriteria(Item.class)    .setProjection( Projections.projectionList()  .add( Projections.id() )  .add( Projections.property(&#8221;description&#8221;) )  .add( Projections.property(&#8221;initialPrice&#8221;) )    );   This query returns a List of Object[], just like HQL or JPA QL would with an  equivalent SELECT clause. An alternative way to specify a property for projection is  the Property class:   session.createCriteria(Item.class)    .setProjection( Projections.projectionList()  .add( Property.forName(&#8221;id&#8221;) )  .add( Property.forName(&#8221;description&#8221;) )  .add( Property.forName(&#8221;initialPrice&#8221;) )    );   In HQL and JPA QL, you can use dynamic instantiation with the SELECT NEW operation  and return a collection of custom objects instead of Object[]. Hibernate  bundles a ResultTransformer for criteria queries that can do almost the same (in  fact, it s more flexible). The following query returns the same result as the previous  one, but wrapped in data transfer objects:   session.createCriteria(Item.class)  .setProjection( Projections.projectionList()  .add( Projections.id()    <br />If you are in need for chaep and reliable webhost to host your website, our recommendation is <a href="http://coldfusion.javaservletwebsitehosting.com">http web server</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-web-server-iis-advanced-query-options-1513-projection-and/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Business web hosting - Querying with criteria and example Result transformers are</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/business-web-hosting-querying-with-criteria-and-example-result-transformers-are/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/business-web-hosting-querying-with-criteria-and-example-result-transformers-are/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 09:11:27 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/business-web-hosting-querying-with-criteria-and-example-result-transformers-are/</guid>
		<description><![CDATA[Querying with criteria and example   Result transformers are also useful if you want to retrieve aliased entities in a  join query:   Criteria crit =    session.createCriteria(Item.class)    .createAlias(&#8221;bids&#8221;, &#8220;b&#8221;)    .createAlias(&#8221;seller&#8221;, &#8220;s&#8221;)    .setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);   List result = crit.list();   [...]]]></description>
			<content:encoded><![CDATA[<p>Querying with criteria and example   Result transformers are also useful if you want to retrieve aliased entities in a  join query:   Criteria crit =    session.createCriteria(Item.class)    .createAlias(&#8221;bids&#8221;, &#8220;b&#8221;)    .createAlias(&#8221;seller&#8221;, &#8220;s&#8221;)    .setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);   List result = crit.list();   for (Object aResult : result) {    Map map = (Map) aResult;    Item item = (Item) map.get(Criteria.ROOT_ALIAS);    Bid bid = (Bid) map.get(&#8221;b&#8221;);    User seller = (User) map.get(&#8221;s&#8221;);    &#8230;   }   First, a criteria query is created that joins Item with its bids and seller associations.  This is an SQL inner join across three tables. The result of this query, in  SQL, is a table where each result row contains item, bid, and user data almost  the same as shown in figure 14.2. With the default transformer, Hibernate returns  only Item instances. And, with the DISTINCT_ROOT_ENTITY transformer, it filters  out the duplicate Item references. Neither option seems sensible what you really  want is to return all information in a map. The ALIAS_TO_ENTITY_MAP transformer  can marshal the SQL result into a collection of Map instances. Each Map has  three entries: an Item, a Bid, and a User. All result data is preserved and can be  accessed in the application. (The Criteria.ROOT_ALIAS is a shortcut for &#8220;this&#8221;.)   Good use cases for this last transformer are rare. Note that you can also implement  your own org.hibernate.transform.ResultTransformer. Furthermore,  HQL and native SQL queries also support a ResultTransformer:   Query q = session.createQuery(    &#8220;select i.id as itemId,&#8221; +    &#8221; i.description as desc,&#8221; +    &#8221; i.initialPrice as price from Item i&#8221;);   q.setResultTransformer( Transformers.aliasToBean(ItemDTO.class) );   This query now returns a collection of ItemDTO instances, and the attributes of  this bean are populated through the setter methods setItemId(), setDesc(),  and setPrice().    A much more common way to define what data is to be returned from a query  is projection. The Hibernate criteria supports the equivalent of a SELECT clause  for simple projection, aggregation, and grouping.    <br />Searching for affordable and proven webhost to host and run your servlet applications? Go to <a href="http://linux.a1websitehosting.net">Linux Web Hosting</a> services and you will find it.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/business-web-hosting-querying-with-criteria-and-example-result-transformers-are/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>CHAPTER 15 Advanced query options As a consequence,  (Hosting your own web site)</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-as-a-consequence-hosting-your-own-web-site/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-as-a-consequence-hosting-your-own-web-site/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 11:08:25 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-as-a-consequence-hosting-your-own-web-site/</guid>
		<description><![CDATA[CHAPTER 15   Advanced query options   As a consequence, criteria queries may return duplicate references to distinct  instances of the root entity, even if you don t apply FetchMode.JOIN for a collection  in your query. The last query example may return hundreds of Item references,  even if you have [...]]]></description>
			<content:encoded><![CDATA[<p>CHAPTER 15   Advanced query options   As a consequence, criteria queries may return duplicate references to distinct  instances of the root entity, even if you don t apply FetchMode.JOIN for a collection  in your query. The last query example may return hundreds of Item references,  even if you have only a dozen in the database. Remember our discussion in   Dynamic fetching strategies with joins,  in chapter 14, section 14.3.1 and look  again at the SQL statement and resultset in figure 14.3.    You can remove the duplicate references in the result List by wrapping it in a  LinkedHashSet (a regular HashSet wouldn t keep the order or the query result).  In HQL and JPA QL, you can also use the DISTINCT keyword; however, there is no  direct equivalent of this in Criteria. This is where the ResultTransformer  becomes useful.   Applying a result transformer   A result transformer can be applied to a query result so that you can filter or marshal  the result with your own procedure instead of the Hibernate default behavior.  Hibernate s default behavior is a set of default transformers that you can  replace and/or customize.    All criteria queries return only instances of the root entity, by default:   List result = session.createCriteria(Item.class)    .setFetchMode(&#8221;bids&#8221;, FetchMode.JOIN)    .setResultTransformer(Criteria.ROOT_ENTITY)    .list();   Set distinctResult = new LinkedHashSet(result);   The Criteria.ROOT_ENTITY is the default implementation of the org.hibernate.transform.ResultTransformer interface. The previous query produces the  same result, with or without this transformer set. It returns all Item instances and  initializes their bids collections. The List probably (depending on the number  of Bids for each Item) contains duplicate Item references.    Alternatively, you can apply a different transformer:   List distinctResult =    session.createCriteria(Item.class)    .setFetchMode(&#8221;bids&#8221;, FetchMode.JOIN)    .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)    .list();   Hibernate now filters out duplicate root entity references before returning the  result this is effectively the same filtering that occurs in HQL or JPA QL if you use  the DISTINCT keyword.    <br />Please visit our <a href="http://php5.premiumwebsitehosting.net">professional web hosting</a> services to find out about cheap and reliable webhost service that will surely answer all your demands.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-as-a-consequence-hosting-your-own-web-site/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Querying with criteria and example Dynamic fetching with  (Web hosting plans)</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-dynamic-fetching-with-web-hosting-plans/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-dynamic-fetching-with-web-hosting-plans/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 14:22:04 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-dynamic-fetching-with-web-hosting-plans/</guid>
		<description><![CDATA[Querying with criteria and example   Dynamic fetching with criteria queries   In HQL and JPA QL, you use the join fetch operation to eagerly fill a collection  or to initialize an object that is mapped as lazy and would otherwise be proxied.  You can do the same using the Criteria [...]]]></description>
			<content:encoded><![CDATA[<p>Querying with criteria and example   Dynamic fetching with criteria queries   In HQL and JPA QL, you use the join fetch operation to eagerly fill a collection  or to initialize an object that is mapped as lazy and would otherwise be proxied.  You can do the same using the Criteria API:   session.createCriteria(Item.class)    .setFetchMode(&#8221;bids&#8221;, FetchMode.JOIN)    .add( Restrictions.like(&#8221;description&#8221;, &#8220;%Foo%&#8221;) );   This query returns all Item instance with a particular collection and eagerly loads  the bids collection for each Item.   A FetchMode.JOIN enables eager fetching through an SQL outer join. If you  want to use an inner join instead (rare, because it wouldn t return items that don t  have bids), you can force it:   session.createCriteria(Item.class)    .createAlias(&#8221;bids&#8221;, &#8220;b&#8221;, CriteriaSpecification.INNER_JOIN)    .setFetchMode(&#8221;b&#8221;, FetchMode.JOIN)    .add( Restrictions.like(&#8221;description&#8221;, &#8220;%Foo%&#8221;) );   You can also prefetch many-to-one and one-to-one associations:   session.createCriteria(Item.class)    .setFetchMode(&#8221;bids&#8221;, FetchMode.JOIN)    .setFetchMode(&#8221;seller&#8221;, FetchMode.JOIN)    .add( Restrictions.like(&#8221;description&#8221;, &#8220;%Foo%&#8221;) );   Be careful, though. The same caveats as in HQL and JPA QL apply here: Eager  fetching more than one collection in parallel (such as bids and images) results in  an SQL Cartesian product that is probably slower than two separate queries. Limiting  the resultset for pagination, if you use eager fetching for collections, is also  done in-memory.    However, dynamic fetching with Criteria and FetchMode is slightly different  than in HQL and JPA QL: A Criteria query doesn t ignore the global fetching  strategies as defined in the mapping metadata. For example, if the bids collection  is mapped with fetch=&#8221;join&#8221; or FetchType.EAGER, the following query results in  an outer join of the ITEM and BID table:   session.createCriteria(Item.class)  .add( Restrictions.like(&#8221;description&#8221;, &#8220;%Foo%&#8221;) );   The returned Item instances have their bids collections initialized and fully  loaded. This doesn t happen with HQL or JPA QL unless you manually query with  LEFTJOINFETCH (or, of course, map the collection as lazy=&#8221;false&#8221;, which results  in a second SQL query).    <br />From our experience, we are can tell you that you can find a reliable and cheap webhost service at <a href="http://www.javaservletwebsitehosting.com">Java Web Hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-dynamic-fetching-with-web-hosting-plans/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>CHAPTER 15 Advanced query options The second way</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-the-second-way/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-the-second-way/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 15:19:57 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-the-second-way/</guid>
		<description><![CDATA[CHAPTER 15   Advanced query options   The second way to express inner joins with the Criteria API is to assign an  alias to the joined entity:   session.createCriteria(Item.class)    .createAlias(&#8221;bids&#8221;, &#8220;b&#8221;)    .add( Restrictions.like(&#8221;description&#8221;, &#8220;%Foo%&#8221;) )    .add( Restrictions.gt(&#8221;b.amount&#8221;, new BigDecimal(99) ) );  [...]]]></description>
			<content:encoded><![CDATA[<p>CHAPTER 15   Advanced query options   The second way to express inner joins with the Criteria API is to assign an  alias to the joined entity:   session.createCriteria(Item.class)    .createAlias(&#8221;bids&#8221;, &#8220;b&#8221;)    .add( Restrictions.like(&#8221;description&#8221;, &#8220;%Foo%&#8221;) )    .add( Restrictions.gt(&#8221;b.amount&#8221;, new BigDecimal(99) ) );   And the same for a restriction on a single-valued association, the seller:   session.createCriteria(Item.class)    .createAlias(&#8221;seller&#8221;, &#8220;s&#8221;)    .add( Restrictions.like(&#8221;s.email&#8221;, &#8220;%hibernate.org&#8221; ) );   This approach doesn t use a second instance of Criteria; it s basically the same  alias assignment mechanism you d write in the FROM clause of an HQL/JPA QL  statement. Properties of the joined entity must then be qualified by the alias  assigned in createAlias() method, such as s.email. Properties of the root entity  of the criteria query (Item) may be referred to without the qualifying alias, or with  the alias &#8220;this&#8221;:   session.createCriteria(Item.class)    .createAlias(&#8221;bids&#8221;, &#8220;b&#8221;)    .add( Restrictions.like(&#8221;this.description&#8221;, &#8220;%Foo%&#8221;) )    .add( Restrictions.gt(&#8221;b.amount&#8221;, new BigDecimal(99) ) );   Finally, note that at the time of writing only joining of associated entities or collections  that contain references to entities (one-to-many and many-to-many) is supported  in Hibernate with the Criteria API. The following example tries to join a  collection of components:   session.createCriteria(Item.class)    .createAlias(&#8221;images&#8221;, &#8220;img&#8221;)    .add( Restrictions.gt(&#8221;img.sizeX&#8221;, 320 ) );   Hibernate fails with an exception and tells you that the property you want to alias  doesn t represent an entity association. We think this feature will likely be implemented  by the time you read this book.    Another syntax that is also invalid, but that you may be tempted to try, is an  implicit join of a single-valued association with the dot notation:   session.createCriteria(Item.class)  .add( Restrictions.like(&#8221;seller.email&#8221;, &#8220;%hibernate.org&#8221;) );   The &#8220;seller.email&#8221; string isn t a property or a component s property path. Create  an alias or a nested Criteria object to join this entity association.    Let s discuss dynamic fetching of associated objects and collections.    <br />We would like to recommend you tested and proved <a href="http://jboss.premiumwebsitehosting.net">virtual web hosting</a> services, which you will surely find to be of great quality.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-the-second-way/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Querying with criteria and example We first look  (Web server info)</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-we-first-look-web-server-info/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-we-first-look-web-server-info/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 16:18:43 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-we-first-look-web-server-info/</guid>
		<description><![CDATA[Querying with criteria and example    We first look at regular joins and how you can express restrictions that involve  associated classes.   Joining associations for restriction   There are two ways to express a join in the Criteria API; hence there are two ways  in which you can [...]]]></description>
			<content:encoded><![CDATA[<p>Querying with criteria and example    We first look at regular joins and how you can express restrictions that involve  associated classes.   Joining associations for restriction   There are two ways to express a join in the Criteria API; hence there are two ways  in which you can use aliases for restriction. The first is the createCriteria()  method of the Criteria interface. This basically means you can nest calls to createCriteria():   Criteria itemCriteria = session.createCriteria(Item.class); itemCriteria.add(    Restrictions.like(&#8221;description&#8221;,  &#8220;Foo&#8221;,  MatchMode.ANYWHERE)   );   Criteria bidCriteria = itemCriteria.createCriteria(&#8221;bids&#8221;); bidCriteria.add( Restrictions.gt( &#8220;amount&#8221;, new BigDecimal(99) ) );   List result = itemCriteria.list();   You usually write the query as follows (method chaining):   List result =  session.createCriteria(Item.class)    .add( Restrictions.like(&#8221;description&#8221;,  &#8220;Foo&#8221;,  MatchMode.ANYWHERE)    )  .createCriteria(&#8221;bids&#8221;)  .add( Restrictions.gt(&#8221;amount&#8221;, new BigDecimal(99) ) )  .list();   The creation of a Criteria for the bids of the Item results in an inner join  between the tables of the two classes. Note that you may call list() on either  Criteria instance without changing the query result. Nesting criteria works not  only for collections (such as bids), but also for single-valued associations (such  as seller):   List result =  session.createCriteria(Item.class)  .createCriteria(&#8221;seller&#8221;)  .add( Restrictions.like(&#8221;email&#8221;, &#8220;%@hibernate.org&#8221;) )  .list();   This query returns all items that are sold by users with a particular email address  pattern.    <br />If you are searching for cheap webhost for your web application, please visit <a href="http://mysql5.a1websitehosting.net">MySQL5 Web Hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-example-we-first-look-web-server-info/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>CHAPTER 15 Advanced query options  (Web design templates) &#8221; where b.ITEM_ID</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-web-design-templates-where-bitem_id/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-web-design-templates-where-bitem_id/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:18:54 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-web-design-templates-where-bitem_id/</guid>
		<description><![CDATA[CHAPTER 15   Advanced query options   &#8221; where b.ITEM_ID = {alias}.ITEM_ID )&#8221;  )  );   This query returns all Item objects which have no bids greater than 100.  (The Hibernate criteria query system is extensible: You could also wrap the  LENGTH() SQL function in your own implementation [...]]]></description>
			<content:encoded><![CDATA[<p>CHAPTER 15   Advanced query options   &#8221; where b.ITEM_ID = {alias}.ITEM_ID )&#8221;  )  );   This query returns all Item objects which have no bids greater than 100.  (The Hibernate criteria query system is extensible: You could also wrap the  LENGTH() SQL function in your own implementation of the Criterion interface.)   Finally, you can write criteria queries that include subqueries.   Writing subqueries   A subquery in a criteria query is a WHERE clause subselect. Just like in HQL, JPA QL,  and SQL, the result of a subquery may contain either a single row or multiple  rows. Typically, subqueries that return single rows perform aggregation.    The following subquery returns the total number of items sold by a user; the  outer query returns all users who have sold more than 10 items:   DetachedCriteria subquery =  DetachedCriteria.forClass(Item.class, &#8220;i&#8221;);   subquery.add( Restrictions.eqProperty(&#8221;i.seller.id&#8221;, &#8220;u.id&#8221;))    .add( Restrictions.isNotNull(&#8221;i.successfulBid&#8221;) )    .setProjection( Property.forName(&#8221;i.id&#8221;).count() );   Criteria criteria = session.createCriteria(User.class, &#8220;u&#8221;)  .add( Subqueries.lt(10, subquery) );   This is a correlated subquery. The DetachedCriteria refers to the u alias; this  alias is declared in the outer query. Note that the outer query uses a less than operator  because the subquery is the right operand. Also note that i.seller.id does  not result in a join, because SELLER_ID is a column in the ITEM table, which is the  root entity for that detached criteria.   Let s move on to the next topic about criteria queries: joins and dynamic  fetching.   15.1.2 Joins and dynamic fetching  Just like in HQL and JPA QL, you may have different reasons why you want to  express a join. First, you may want to use a join to restrict the result by some property  of a joined class. For example, you may want to retrieve all Item instances that  are sold by a particular User.   Of course, you also want to use joins to dynamically fetch associated objects or  collections, as you d do with the fetch keyword in HQL and JPA QL. In criteria  queries you have the same options available, with a FetchMode.    <br />From our experience, we can recommend <a href="http://php.javaservletwebsitehosting.com">PHP Web Hosting</a> services, if you need affordable webhost to host and run your web application.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-web-design-templates-where-bitem_id/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Ecommerce web host - Querying with criteria and example We think both</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/ecommerce-web-host-querying-with-criteria-and-example-we-think-both/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/ecommerce-web-host-querying-with-criteria-and-example-we-think-both/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 18:20:18 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/ecommerce-web-host-querying-with-criteria-and-example-we-think-both/</guid>
		<description><![CDATA[Querying with criteria and example   We think both these options are ugly, even after spending five minutes trying to  format them for maximum readability. JDK 5.0 static imports can help improve  readability considerably, but even so, unless you re constructing a query on the fly,  the HQL or JPA QL [...]]]></description>
			<content:encoded><![CDATA[<p>Querying with criteria and example   We think both these options are ugly, even after spending five minutes trying to  format them for maximum readability. JDK 5.0 static imports can help improve  readability considerably, but even so, unless you re constructing a query on the fly,  the HQL or JPA QL string is much easier to understand.    You may have noticed that many standard comparison operators (less than,  greater than, equals, and so on) are built into the Criteria API, but certain operators  are missing. For example, any arithmetic operators such as addition and  division aren t supported directly.   Another issue is function calls. Criteria has built-in functions only for the  most common cases such as string case-insensitive matching. HQL, on the other  hand, allows you to call arbitrary SQL functions in the WHERE clause.   The Criteria API has a similar facility: You can add an arbitrary SQL expression  as a Criterion.   Adding arbitrary SQL expressions   Let s assume you want to test a string for its length and restrict your query result  accordingly. The Criteria API has no equivalent to the LENGTH() function in  SQL, HQL, or JPA QL.    You can, however, add a plain SQL function expression to your Criteria:   session.createCriteria(User.class)    .add( Restrictions.sqlRestriction(    &#8220;length({alias}.PASSWORD) < ?",    5,    Hibernate.INTEGER    )    );   This query returns all User objects that have a password with less than 5 characters.  The {alias} placeholder is needed to prefix any table alias in the final SQL;  it always refers to the table the root entity is mapped to (USERS in this case). You  also use a position parameter (named parameters aren t supported by this API)  and specify its type as Hibernate.INTEGER. Instead of a single bind argument and  type, you can also use an overloaded version of the sqlRestriction() method  that supports arrays of arguments and types.    This facility is powerful for example, you can add an SQL WHERE clause subselect  with quantification:   session.createCriteria(Item.class)    .add( Restrictions.sqlRestriction(    "'100' > all&#8221; +    &#8221; ( select b.AMOUNT from BID b&#8221; +    <br />If you are looking for affordable and reliable webhost to host and run your business application visit our <a href="http://domain.premiumwebsitehosting.net">ftp web hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/ecommerce-web-host-querying-with-criteria-and-example-we-think-both/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>CHAPTER 15 Advanced query options session.createCriteria(User.class) .add( Restrictions.like(&#8221;username&#8221;,</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-sessioncreatecriteriauserclass-add-restrictionslikeusername/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-sessioncreatecriteriauserclass-add-restrictionslikeusername/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 20:16:15 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-sessioncreatecriteriauserclass-add-restrictionslikeusername/</guid>
		<description><![CDATA[CHAPTER 15   Advanced query options   session.createCriteria(User.class)  .add( Restrictions.like(&#8221;username&#8221;, &#8220;G%&#8221;) );   session.createCriteria(User.class)  .add( Restrictions.like(&#8221;username&#8221;, &#8220;G&#8221;, MatchMode.START) );   The allowed MatchModes are START, END, ANYWHERE, and EXACT.    You often also want to perform case-insensitive string matching. Where you d  resort to a function [...]]]></description>
			<content:encoded><![CDATA[<p>CHAPTER 15   Advanced query options   session.createCriteria(User.class)  .add( Restrictions.like(&#8221;username&#8221;, &#8220;G%&#8221;) );   session.createCriteria(User.class)  .add( Restrictions.like(&#8221;username&#8221;, &#8220;G&#8221;, MatchMode.START) );   The allowed MatchModes are START, END, ANYWHERE, and EXACT.    You often also want to perform case-insensitive string matching. Where you d  resort to a function such as LOWER() in HQL or JPA QL, you can rely on a method  of the Criteria API:   session.createCriteria(User.class)  .add( Restrictions.eq(&#8221;username&#8221;, &#8220;foo&#8221;).ignoreCase() );   You can combine expressions with logical operators.   Combining expressions with logical operators   If you add multiple Criterion instances to the one Criteria instance, they re  applied conjunctively (using and):   session.createCriteria(User.class)  .add( Restrictions.like(&#8221;firstname&#8221;, &#8220;G%&#8221;) )  .add( Restrictions.like(&#8221;lastname&#8221;, &#8220;K%&#8221;) );   If you need disjunction (or), there are two options. The first is to use Restrictions.or() together with Restrictions.and():   session.createCriteria(User.class)  .add(  Restrictions.or(    Restrictions.and(  Restrictions.like(&#8221;firstname&#8221;, &#8220;G%&#8221;),  Restrictions.like(&#8221;lastname&#8221;, &#8220;K%&#8221;)    ),  Restrictions.in(&#8221;email&#8221;, emails)  )  );   The second option is to use Restrictions.disjunction() together with  Restrictions.conjunction():   session.createCriteria(User.class)  .add( Restrictions.disjunction()    .add( Restrictions.conjunction()  .add( Restrictions.like(&#8221;firstname&#8221;, &#8220;G%&#8221;) )  .add( Restrictions.like(&#8221;lastname&#8221;, &#8220;K%&#8221;) )    )  .add( Restrictions.in(&#8221;email&#8221;, emails) )  );    <br />We highly recommend you visit <a href="http://coldfusion.premiumwebsitehosting.net">web and email hosting</a> services if you need stable and cheap web hosting platform for your web applications.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/chapter-15-advanced-query-options-sessioncreatecriteriauserclass-add-restrictionslikeusername/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Querying with criteria and  (Make web site) example The Criteria API</title>
		<link>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-make-web-site-example-the-criteria-api/</link>
		<comments>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-make-web-site-example-the-criteria-api/#comments</comments>
		<pubDate>Sat, 31 May 2008 22:13:03 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>j2ee</category>
		<guid isPermaLink="false">http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-make-web-site-example-the-criteria-api/</guid>
		<description><![CDATA[Querying with criteria and example   The Criteria API and the org.hibernate.criterion package offer many  other operators besides eq() you can use to construct more complex expressions.   Creating comparison expressions   All regular SQL (and HQL, JPA QL) comparison operators are also available via the  Restrictions class:   [...]]]></description>
			<content:encoded><![CDATA[<p>Querying with criteria and example   The Criteria API and the org.hibernate.criterion package offer many  other operators besides eq() you can use to construct more complex expressions.   Creating comparison expressions   All regular SQL (and HQL, JPA QL) comparison operators are also available via the  Restrictions class:   Criterion restriction =    Restrictions.between(&#8221;amount&#8221;,    new BigDecimal(100),    new BigDecimal(200) );   session.createCriteria(Bid.class).add(restriction);   session.createCriteria(Bid.class)  .add( Restrictions.gt(&#8221;amount&#8221;, new BigDecimal(100) ) );   String[] emails = { &#8220;foo@hibernate.org&#8221;, &#8220;bar@hibernate.org&#8221; };   session.createCriteria(User.class)    .add( Restrictions.in(&#8221;email&#8221;, emails) );   A ternary logic operator is also available; this query returns all users with no email  address:   session.createCriteria(User.class)  .add( Restrictions.isNull(&#8221;email&#8221;) );    You also need to be able to find users who do have an email address:   session.createCriteria(User.class)  .add( Restrictions.isNotNull(&#8221;email&#8221;) );   You can also test a collection with isEmpty(), isNotEmpty(), or its actual size:   session.createCriteria(Item.class)  .add( Restrictions.isEmpty(&#8221;bids&#8221;));   session.createCriteria(Item.class)  .add( Restrictions.sizeGt(&#8221;bids&#8221;, 3));   Or you can compare two properties:   session.createCriteria(User.class)  .add( Restrictions.eqProperty(&#8221;firstname&#8221;, &#8220;username&#8221;) );   The criteria query interfaces also have special support for string matching.   String matching   For criteria queries, wildcarded searches may use either the same wildcard symbols  as HQL and JPA QL (percentage sign and underscore) or specify a MatchMode.  The MatchMode is a convenient way to express a substring match without string  manipulation. These two queries are equivalent:    <br />You need excellent and relaible webhost company to host your web applications? Then pay a visit to <a href="http://www.a1websitehosting.net">Inexpensive Web Hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://j2ee.javaservletwebsitehosting.com/j2ee/querying-with-criteria-and-make-web-site-example-the-criteria-api/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
