-->
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.  [ 1 post ] 
Author Message
 Post subject: @orderby sql server 2005 arrayList usage
PostPosted: Tue Jun 10, 2008 7:20 am 
Newbie

Joined: Tue Jun 10, 2008 6:53 am
Posts: 1
Hi,
I'm trying to sort an arrayList using the annotation @orderBy.
I'm sure it's user error/inexperience with hibernate which is the problem. I have checked the logs coming out and i can't see any evidence of an order by happening.

I'm trying to order an arraylist of points by a point_id field. The points will not be unique.

Q. Is this possible?
Q. Am i using the correct syntax?
Q. Do i need to use the hibernate import not the javax.persistence one?

//should this be a hibernate library instead?
Code:
import javax.persistence.OrderBy;

@Entity
@Table(name = "polygons")
public class Polygon
{

@ManyToOne
@JoinColumn(name = "parent_session")
private Session parentSession;

@OneToMany(mappedBy = "parentPolygon", cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE })
private List<Point> points = new ArrayList<Point>();

@OrderBy("point_id, asc")//also tried ("point_id asc")
Code:
public List<Point> getPoints()
{
   return points;
}}

...

//points table extract below
@Entity
@Table(name = "points")
public class Point
{
@Id
@GeneratedValue
@Column(name = "Id")
private long id;

@Column(name = "point_id")
private int point_id;
Code:
@ManyToOne
@JoinColumn(name = "parent_polygon")
private Polygon parentPolygon;

}


http://www.onjava.com/pub/a/onjava/2007 ... tml?page=2 implied I could do this.

Many thanks,
s


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

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.