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 Sepp,

EclipseLink can work in JPA and with Native API. You can even use JPA API and native metadata in combination - which might be a good thing for you to consider since it will allow you to avoid using annotations and orm.xml, but allow you to still use the standardized API>

The construct you are interested in is called a Project by EclipseLink. A Project holds the metadata about a project. You should be able to access the project and modify it through some of our JPA customization events, or in native API through our prelogin event.

  Before JPA, the typical way to use EclipseLink (then called TopLink) was to
use the MappingWorkbench to describe your metadata and export either Java code
or an XML document that contains that metadata.  I realize that will not get you
all the way to your goal.  If you use the facility to export java code, it will,
however give you a way to generate and see the type of java code that
EclipseLink expects for its descriptors and mappings - a way to prototype.

  Can you provide a more in-depth description of the mapping you are trying to
create between target_table and table_between.  i.e. The classes involved and
the relevant instance variables and the tables involved.  The reason I ask is
that based on your initial description, I was under the impression this is a
typical 1-M mapping, but it seems it may not be.

  There is an JPA based example of how you might work without predefined
classes here:

http://wiki.eclipse.org/EclipseLink/Examples/JPA/Dynamic

  Although it is JPA-based, it may provide you with some ideas.

-Tom

Robert Wimmer wrote:
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) <http://wiki.eclipse.org/Configuring_a_Relational_One-to-Many_Mapping_%28ELUG%29> does not help me in any way.


------------------------------------------------------------------------
Hol dir noch heute die neue Beta des Windows Live Messengers! Hier klicken! <http://download.live.com/>


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top