-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Will there be future support for Criteria API-ish annots?
PostPosted: Wed Nov 16, 2005 11:42 am 
Beginner
Beginner

Joined: Sat Sep 17, 2005 10:41 am
Posts: 49
I'm thinking of something similar to the @Where clause, but using property names instead of SQL or HQL.

Use case:

Code:
@Entity (AccessType.FIELD)
public class Disk
{
@Id
protected Long id ;

// current solution, mapping using @Where
@OneToMany (mappedBy = "disk")
@OrderBy ("listOrder")
@Where (clause = "parent_id is null")
protected List<Directory> directory ;

// proposed alternate mapping using @Criterion
@OneToMany (mappedBy = "disk")
@OrderBy ("listOrder")
@Criterion (isNull = "parent")
protected List<Directory> directory ;
}

@Entity (AccessType.FIELD)
{
@Id
protected Long id ;
protected Integer listOrder ;
protected String name ;

@ManyToOne (fetch = FetchType.LAZY)
protected Disk disk ;

@ManyToOne (fetch = FetchType.LAZY)
protected Directory parent ;

@OneToMany (mappedBy = "parent")
@OrderBy ("listOrder")
protected List<Directory> children ;
}


Where "Disk" has a list of root directories (parentless directories). The idea is to not be reliant on the physical mapping of the "parent_id" column using the @Where clause.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 8:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This should be doable, add a JIRA issue, and even better, provide a patch to make it happen faster.
@javax.persistence.OrderBy
@org.hibernate.annotations.OrderBy
Have similar concepts

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 10:59 am 
Beginner
Beginner

Joined: Sat Sep 17, 2005 10:41 am
Posts: 49
emmanuel wrote:
This should be doable, add a JIRA issue, and even better, provide a patch to make it happen faster.


http://opensource2.atlassian.com/projec ... se/ANN-155


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 1:40 pm 
Beginner
Beginner

Joined: Sat Sep 17, 2005 10:41 am
Posts: 49
Emmanuel,

Regarding the criteria API being to verbose...

Maybe to lessen the scope, the annotations should only support a subset. I'm thinking Restrictions, since those cover most of the use cases. These annotations should really only be used for fetching entity relationships.

At the very least, perhaps this can be as simple as an HQL equivalent to the existing @Where annotation.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 7:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't really buy the partial support idea. HQL is really fine here.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.