-->
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: how to retrieve first object of a list poperty using query
PostPosted: Mon Jun 01, 2009 1:28 am 
Newbie

Joined: Mon Jun 01, 2009 1:20 am
Posts: 2
Hi All,

I have two tables " application " and " user ". So Application has @ManyToMany relation with User. below is the code for @ManyToMany.

Application.java
---------------------
protected List<User> users= new ArrayList<User>(0);

@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable( joinColumns=@JoinColumn(name="application_fk"),
inverseJoinColumns=@JoinColumn(name="user_fk"))
@ForeignKey(name="FK_USER_APPLICATION",
inverseName="FK_APPLICATION_USER")
@IndexColumn(name="applicant_order", base=0)
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users= users;
}

i want to select first object in the "users" as column in the query . some thing like below code.

select users[0].zipCode , count(users[0].zipCode),
sum(amount) , avg(amount) from Application

users[0] is the first object in the "users" list. do we have provision for doing this in hibernate.

can some one please help me to solve this issue. has any one come across such issue.

regards,
ganesh


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.