Skip to main content

JDBC's future, or: DataSet relations?

2 replies [Last post]
Joined: 2004-07-04
Points: 0

What about creating a set of annotations to note one-to-many or many-to-many relations in the database?

For example, I could say:

interface MyQueries extends BaseQuery {
@Query("select id, name, age from students")
@Relation("Classes", "select name from classes c, 0class_student cs where student_id = {id}")
DataSet getAllStudents();

DataSet students = mq.getAllStudents();
DataSet classrooms = students.getChildRecords("Classes");

Or something similar, where the first parameter of @Relation is the relation name, the second parameter is the selection statement. The parameters for the selection statement come from the parent DataSet - id, in this case, is the id value of the Student instance.

Then, when using the DataSet instance, you could call the getChildRecords(String relationName) method to get all the classroom records.

Also, an option which I prefer better, is this:

@Relation("Classes", "select name from classes c, class_student cs", "cs.student_id = {id}")

It's a subtle difference, but it allows for disconnected work, because then the framework could just select all the classes and their connections, and do this filtering in memory.

I know I wrote a lot - But this is my idea, and I thought I might get some comments, or maybe even a "We're working on something for relations that is even better".

Thanks ahead,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-13
Points: 0

Thanks for the suggestion. What you are looking for is more of an ORM solution which is what the Java Persistance API is providing. The EoD features are not intended to be an ORM solution.

Joined: 2004-07-04
Points: 0

No reponses means that no-one is interested in some more improvements in the JDBC API?