Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] customize OneToMany Mapping

Hi Tom,

to answer your question

> Have you taken a look at any of the getting started documentation?

yes, i have taken a look to all of these documents before posting here - and some of them are really helpfull. i also built successfully some projects
useing

- Sessions,
- Classdescriptors,
- DirectFieldMappings,
- OneToManyMappings,
- OneToManyMappings
- ExpressionBuilder
...
 
with oracle and postgresql using eclipse-link. the most helpfull document for me was 

> - Some sample code from our test framework can be found here:
> http://fisheye2.atlassian.com/browse/~raw,r=4604/eclipselink/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/models/employee/relational/EmployeeProject.java

to give you an example about my knowledge in eclipse-link

        OneToManyMapping mtm = new OneToManyMapping();
        mtm.setAttributeName("contacts");
        mtm.setReferenceClass(Contact.class);
        mtm.addTargetForeignKeyFieldName("contact.person_id", "person.id");
        mtm.dontUseIndirection();
        personDescriptor.addMapping(mtm);
 
so far i am able to generate an OTM mapping. back to the original problem

> > i need to create a OneToManyMapping for the following problem
> >
> > SELECT * FROM target_table
> >
> > JOIN table_between ON table_between.target_table_id = target_table.id
> >
> > WHERE table_between. source_id = ?

some pseudo-code (which methods in which order) really would help me a lot.

Another problem is, that in the intended project the persistence layer should be as generic as possible and use the eclipse-link "native" Java-API. no JPA, no XML and at least no annotations. The mapping should be generated dynamic from metadatdescription held in the DB itself. The intended way to map the database data is without the usage of  one java class per ClassDescriptor.

unlike

public class Address {

  String firstname,lastname ....

}

we would like to use something like

//AddressTupel = new TupelMappingInterface();
...
AddressTupel.addField("firstname",String.class);
AddressTupel.addField("lastnam",String.class);
...

ClassDescriptor.setJavaInterface(AddressTupel);

regards and thanks in advance

Sepp

P.S.: something like

public void customize(ClassDescriptor descriptor) { 
OneToManyMapping mapping = new OneToManyMapping();

// configure mapping
...

// add mapping to descriptor
descriptor.addMapping(mapping);
}
as found on http://wiki.eclipse.org/Configuring_a_Relational_One-to-Many_Mapping_(ELUG) does not help me in any way.



Hol dir noch heute die neue Beta des Windows Live Messengers! Hier klicken!

Back to the top