Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] ManyToManyMapping.setSourceRelationKeyFieldName(String name) act as "add", not "set"

What I did, and it worked (but it has succeed only because I've only one field in the whole process) is: ManyToManyMapping map = (ManyToManyMapping)cdg.getMappingForAttributeName("uriPath");
        map.setRelationTableName("vi_grupo_uripath");
        map.getSourceRelationKeyFields().clear();
map.setSourceRelationKeyFieldName("vi_grupo_uripath.grupo_id");
        map.getTargetRelationKeyFields().clear();
map.setTargetRelationKeyFieldName("vi_grupo_uripath.uripath_id");

But IMHO, if the method "add" something, then its name should not be "set"...

Regards,

Edson Richter


Em 30/10/2013 15:46, Edson Richter escreveu:
I've to make some customization in the descriptor at application start, and there is an weird behavior I can't deal with. In the following code, I want to change from tables to a bunch of views from a remote database:

public class JPACustomizer implements SessionCustomizer {
  public void customize(Session session) throws Exception {
        ClassDescriptor cdg = session.getDescriptor(Grupo.class);

ManyToManyMapping map = (ManyToManyMapping)cdg.getMappingForAttributeName("uriPath");
        map.setRelationTableName("vi_grupo_uripath");
map.setSourceRelationKeyFieldName("vi_grupo_uripath.grupo_id");
map.setTargetRelationKeyFieldName("vi_grupo_uripath.uripath_id");
...

The problem is that when I run the application, I still have the mapping for old table - the "set" just "added" another field mapping to SourceRelation and TargetRelation collections.

How to deal with that? What is the right way to change the relation at runtime?

Thanks,

Edson Richter

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





Back to the top