-->
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.  [ 2 posts ] 
Author Message
 Post subject: JoinColumn annotation in resultset from procedure.Pls help
PostPosted: Mon Feb 22, 2016 9:18 pm 
Newbie

Joined: Mon Feb 22, 2016 9:00 am
Posts: 1
I am using MVC pattern I have two tables : Employee and Address

say, Employee is like

-------------------
Id | Name | DeptId
-------------------
101 | Jake | 501
102 | Donald | 502

and I have one Department table like

-----------------------------
DeptId | Name | Description
-----------------------------
501 | IT | software assistance
502 | HR | Human resources

Now since I am using MVC these tables are mapped to classes like

@Table(name="Employee")
Class Employee{
@Id
@Column(name="Id")
private Long id;

@Column(name="Name")
private String name;

@Column(name="DeptId")
private Long deptId;

@ManyToOne
@JoinColumn(name="DeptId", referencedColumnName="id", insertable=false,updatable=false)
private Department dept;

//getters and setters go here
}

and the other class Department (mapped to Department table)

@Table(name="Department")
Class Department{
@Id
@Column(name="Id")
private Long id;

@Column(name="Name")
private String name;

@Column(name="Description")
private String description;

//getters and setters go here
}

notice that Employee class has reference to an object of Department class. This @ManyToOne and @JoinColumn annotations helps us in automatically retrieving corresponding department object along with an employee object

Its easy with queries directly in code but how can this be done if I am to use only procedures or functions in my code I have tried different methods , but it doesn't seem to help

Sometimes I get error something like Cannot return resultset from a stored procedure in oracle 10g

Can anyone please clarify. Also I have to use JNDI

Can I get my result from the procedure/function in a way that it returns me List<Employee> (not a raw resultset which I myself have to sort out into objects) . It should be possible using hibernate no ?

thanks


Top
 Profile  
 
 Post subject: Re: JoinColumn annotation in resultset from procedure.Pls help
PostPosted: Tue Feb 23, 2016 6:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
Sure it works. Check out this example.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.