[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2308) Adding predicates to the join condition using Criteria Query

Steve Ebersole (JIRA) noreply at atlassian.com
Thu Nov 19 23:35:09 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34685#action_34685 ] 

Steve Ebersole commented on HHH-2308:
-------------------------------------

This patch adds both of the following new methods to Criteria:
{code}
	/**
	 * Join an association using the specified join-type, assigning an alias
	 * to the joined association.
	 * <p/>
	 * The joinType is expected to be one of {@link #INNER_JOIN} (the default),
	 * {@link #FULL_JOIN}, or {@link #LEFT_JOIN}.
	 *
	 * @param associationPath A dot-seperated property path
	 * @param alias The alias to assign to the joined association (for later reference).
	 * @param joinType The type of join to use.
	 * @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause)
	 *
	 * @return this (for method chaining)
	 *
	 * @throws HibernateException Indicates a problem creating the sub criteria
	 */
	public Criteria createAlias(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException;

	/**
	 * Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
	 * assigning the given alias and using the specified join type.
	 *
	 * @param associationPath A dot-seperated property path
	 * @param alias The alias to assign to the joined association (for later reference).
	 * @param joinType The type of join to use.
	 * @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause)
	 *
	 * @return the created "sub criteria"
	 * 
	 * @throws HibernateException Indicates a problem creating the sub criteria
	 */
	public Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException;

{code}

> Adding predicates to the join condition using Criteria Query
> ------------------------------------------------------------
>
>                 Key: HHH-2308
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2308
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: query-criteria
>    Affects Versions: 3.2.1
>         Environment: Linux Using MS SQLServer
>            Reporter: Ben Grant
>            Assignee: Steve Ebersole
>             Fix For: 3.5
>
>         Attachments: hibernate-3.3.2.GA-createAlias_withClause.patch, hibernate-3.3.2.GA-createAlias_withClause.zip, hibernate-joinOn-sorted.ZIP, hibernate-joinOn.ZIP, hibernate-outer-join-criteria-trunk.diff, hibernate-outer-join-criteria.diff
>
>
> I have two tables 
> Table A 
> ||Col_1||Col_2|| 
> |London| UK | 
> |Liverpool| UK | 
> | New York | USA | 
> Table B 
> ||Col_1||Col_2|| Col_3|| 
> | UK | Europe | 0 
> | USA | Americas | 1 
> Using the Criteria class, Restriction Class and FetchMode, Hibernate manages to create a query that looks like this 
> select distinct top 2000 
> this_.Col_1 as y0_, TableB3_.Col2 as y1_ 
> from TableA this_ 
> left outer join TableB TableB3_ on this_.Col_2= TableB3_.Col_1 
> where TableB3_.Col_3=1 
> When really i need the query to be like this 
> select distinct top 2000 
> this_.Col_1 as y0_, TableB3_.Col2 as y1_ 
> from TableA this_ 
> left outer join TableB TableB3_ on this_.Col_2= TableB3_.Col_1 AND TableB3_.Col_3=1 
> currently their isn't any know way for hibernate to adjust or apply filters within the join clause.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list