Edwin Nels Johnson

Greenhorn
+ Follow
since Mar 13, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Edwin Nels Johnson

I have a db table called Task. It has a structure like this:

taskid bigint(20) autoincrement identity
taskname varchar(255)
parentTaskId bigint(20)


The idea is to have a series of tasks just like MS Project. Some tasks can be subtasks of other parent tasks. The parentTaskId column will hold a reference to the TaskId from the parent row. When it comes to ORM, then I will have one to many and many to one relationships that refer to the same Entity.

I am trying to figure out how to implement this using Toplink Essentials - I found a Hibernate example that recommended something like this:

@Entity
private class Task{

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long TaskId

@ManyToOne
private Task parentTaskId;

@OneToMany(mappedBy="parentTaskId")
private Collection<Task> subTasks;


}



I am missing a few pieces though - when I call a named native query to fetch Task objects, I want the parentTaskId property to be populated with a Task object, not just the id from the row. And if a task is a parent task, I would like the subTasks collection to be populated with all the Task objects that have their parentTaskId column set as that TaskId.

Could someone point me to an example of this using Toplink?

Thanks Ashish - I'm looking forward to learning more about Spring Roo and trying it out.


12 years ago
Hi Ashish,

Since Spring Roo generates code for you - are there any mechanisms to protect any customization that you do to that code? If another Spring Roo command is issued to alter an entity class for example, will this wipe out any customization?

12 years ago