Cannot find FactoryHelper / ProxyFactory in source

9 views
Skip to first unread message

Ryan Griffith

unread,
Sep 16, 2020, 11:38:42 AM9/16/20
to mybatis-user
I'm a bit new to Java, but have used .Net since it was introduced in the early 2000's. I'm still learning about how things are done in Java and I think one of those aspects is eluding me at the moment.

For context, I'm using MyBatis v3.4.6 with Spring MVC. I have a MyBatis entity with lazy-loaded associations so my class ends up being a Proxy class. I'm looking to determine the super class of that class (basically I'm looking for my actual entity class type not the proxy class type).

I used javassist.util.proxy.ProxyFactory.isProxyClass(this.getClass()) which returned false despite my class actually being a Proxy class.

I then found org.apache.ibatis.javassist.util.proxy.ProxyFactory. When calling ProxyFactory.isProxyClass() from this class, I get an appropriate true response.

Now,  because I'm interested in how all this works, I looked for this class in my MyBatis repository at this version, 3.4.6. I cannot find any reference to this ProxyFactory class nor can I find a reference to the FactoryHelper class. I also noticed that these classes look to mimic the classes of the same name in the javassist.util.proxy package.

Is there some way in java to have a package (javassist) masquerade within another package (org.apache.ibatis.javassis)? What am I missing here?




Iwao AVE!

unread,
Sep 16, 2020, 3:03:55 PM9/16/20
to mybatis-user
Hello Ryan,

We use maven-shade-plugin [1] to include Javassist (and OGNL) source when building the binary (i.e. mybatis-x.x.x.jar).
For how or why, this answer may be informative.

If you want to use ProxyFactory or FactoryHelper in your code, you should add Javassist to your project's dependencies and use (=import) the classes in `javassist` package instead of the ones in `org.apache.ibatis.javassist` package.


Regards,
Iwao


--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/d260013b-283a-49e5-b5db-58ea1859d5a1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages