-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: mappedBy references wrong field after obfuscation
PostPosted: Thu Jul 07, 2011 5:14 am 
Newbie

Joined: Fri Sep 10, 2010 2:44 am
Posts: 2
Hi!

We use a bidirectional ManyToMany connection with a Jointable like this:
Code:
@Entity(name="group")
public class Group {
    ...
    @ManyToMany(targetEntity = User.class)
    @JoinTable(joinColumns = @JoinColumn(name = "group_id"), inverseJoinColumns = @JoinColumn(name = "user_id"))
    private Set<User> users = new HashSet<User>();
}

@Entity
public class User {
    ...
    @ManyToMany(mappedBy = "users", targetEntity = Group.class)
    private Set<Group> groups = new HashSet<Group>();
}

this works great!

After the Obfuscation, the field names are renamed as expected. So maybe it looks like this:
Code:
@Entity(name="group")
public class A {
    ...
    @ManyToMany(targetEntity = B.class)
    @JoinTable(joinColumns = @JoinColumn(name = "group_id"), inverseJoinColumns = @JoinColumn(name = "user_id"))
    private Set<B> a = new HashSet<B>();
}

@Entity
public class B {
    ...
    @ManyToMany(mappedBy = "users", targetEntity = A.class)
    private Set<A> a = new HashSet<A>();
}

Not the Problem is, that the mappedBy attribute for the field a in the class B still refers to the field "users" which has been obfuscated and renamed to simply "a". So is there a way (except telling the obfuscator not to change the field name) to keep the correct reference in the "mappedBy" attribute? The @Column(name="users") Annotation for A.a will not work, because "users" is not a column in the table "group"

Thanks


Top
 Profile  
 
 Post subject: Re: mappedBy references wrong field after obfuscation
PostPosted: Wed Sep 05, 2012 12:16 pm 
Beginner
Beginner

Joined: Tue Aug 29, 2006 8:08 am
Posts: 34
Man , I haven't even gone as far as you and I am quite desperate ...could you please help me ?

My Proguard config is shown below (as ant task). My problem is that no matter what I try, Annotations do not remain at all if I add the option -keepattributes *Annotation* and they remain exactly as they are If I remove it...... no way to get them at least as obfuscated as you do...... pleeeeaaase heeeelp :( google does not show much people with these requirements ....


Code:
          <proguard>
            -verbose
            -printmapping "${target.dir}/onetomany.map"
                -libraryjars "${java.lib}/libgcj-4.4.jar"
                -libraryjars "${java.lib}/ant-antlr.jar"
                 -libraryjars "${java.lib}/hibernate-commons-annotations-3.2.0.Final.jar"
                 -libraryjars "${java.lib}/hibernate-core-3.6.9.Final.jar"
                 -libraryjars "${java.lib}/dom4j.jar"
                 -libraryjars "${java.lib}/slf4j-api.jar"
                 -libraryjars "${java.lib}/geronimo-jpa-2.0-spec.jar"
                 -libraryjars "${java.lib}/geronimo-jta_1.1_spec.jar"           
                 -libraryjars "${java.lib}/mysql-connector-java.jar"
                 -libraryjars "${java.lib}/commons-collections3.jar"
                 -libraryjars "${java.lib}/javassist.jar"
                -injars     "${target.dir}/${jar.name}"
                -outjars    "${target.dir}/${jar.obfuscated.name}"
                -keep class net.just.to.add.keep.Main { public static void main(java.lang.String[]);}            
               -keepattributes *Annotation*
          </proguard>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.