Using interfaces instead of classes as entyties
------------------------------------------------
Key: HHH-2416
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2416
Project: Hibernate3
Type: Improvement
Components: core
Environment: Hibernate
Reporter: Pedro da Silva Garcia
Priority: Minor
Hi folks,
I'm writing to express some of my ideas for a better ORM framework.
First i think it would be very nice to be able to map the tables to an interface instead
of to a class. This would give me the ability to have many different classes implementing
the same interface.
For example:
If I have a project that uses Struts 1. I would be able to use a form beam as a value
object to persist data.
But this is just the begging of what I am thinking about.
The good this would be when a retrieve data from the database.
Example:
Instead of doing this
1) session.get(Cat.class, id);
It would be great to do something like this
2) session.get(CatForm.class, ICat.class, id);
and to do this
3) session.get (ICat.class, id);
In this last case Hibernate would have to generate a class that implements ICat and return
it (Kind like what Tapestry framework does with the page object).
In real life I would use the example number 2 in situations like this:
public class CatDAO {
public ICat get(Integer id, Class<ICat> returnType){
return (ICat)session.get(returnType, ICat.class, id);
}
...
}
And with the interfaces I would be able to merge entyties like
public class EmployeeDepartment implements IEmployee, IDepartment{
private Integer employeeId;
private Integer departmentId;
}
Or I could create a class to use as a query with the union of different tables.
And in the case of complex forms with data form many different tables I simply would
create a form class that implements all those different interfaces and when I do a save,
all of the different entyties represented by this class would be saved.
Thanks for your attention,
Pedro
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira