Hi Santa, Currently there's no way to prevent the proxies from being created. I started looking into making that work, but the code proved to be more involved than I thought and I haven't gotten back to it.
Changing the schema version should cause the proxies to be removed when the entities are serialized. There are some conditions (I think the entities need to be detached), but for at least some use cases it should still work. Could you check whether the entities are detached when you serialize them? -mike On Wed, Apr 27, 2011 at 10:21 PM, tovarisch <[email protected]>wrote: > Hi Michael, > > I don't want to hijack your conversation, but I have the same problem, I > have followed the tips suggested on this thread, and using schema version > 2.0 still generates the proxies. GWT throws an exception because > org.apache.openjpa.util.java$util$ArrayList$proxy is an unknown class for > its serialization system. > > Santa. > > > Jason Ferguson wrote: > > > > It looks like I have 1.0. I'll try switching over to 2.0 tonight and > > let you know. > > > > Jason > > > > On Mon, Apr 11, 2011 at 9:58 AM, Michael Dick > > <[email protected]> wrote: > >> I took another look at the proxy code again and realized that my > >> persistence.xml file was using version 1.0 as the schema version. > >> > >> Changing it to version 2.0 lead to results more like what you're looking > >> for. Proxies still remain in the entities after the entity is detached, > >> but > >> will be removed when the entities are serialized. > >> > >> Jason, could you check what version you have specified in > >> persistence.xml? > >> > >> Thanks > >> -mike > >> > >> > >> > >> On Mon, Apr 11, 2011 at 9:22 AM, Michael Dick > >> <[email protected]>wrote: > >> > >>> Hi Jason, > >>> > >>> Detachment and proxy classes are fairly complicated in OpenJPA. Like > >>> Rick > >>> mentioned I've started looking at what it'd take to remove the proxies > >>> and > >>> it's turned into a more sizable effort than I'd hoped. > >>> > >>> OpenJPA was originally designed with JEE application servers in mind > and > >>> it > >>> answers that need well. Geronimo, WebSphere, and at least some versions > >>> of > >>> WebLogic use OpenJPA as the basis for their persistence framework. > >>> > >>> Outside of that area OpenJPA may require some massaging. > >>> > >>> There has been some work done with GWT. The OpenTrader example : > >>> http://openjpa.apache.org/opentrader.html uses some parts of GWT, but > >>> the > >>> documentation is a little light in places. The source code is available > >>> though, and may be of some help (I have no experience with GWT and > can't > >>> really judge). > >>> > >>> HTH > >>> -mike > >>> > >>> On Sat, Apr 9, 2011 at 6:18 PM, Jason Ferguson > >>> <[email protected]>wrote: > >>> > >>>> I'm running with 2.1.0. I figured if I was going to learn to use JPA > >>>> versus Hibernate, I may as well use the most current version. > >>>> > >>>> So let me see if I'm doing this right. I added the following property > >>>> to persistence.xml: > >>>> > >>>> <property name="openjpa.DetachState" > >>>> value="loaded(LiteAutoDetach=true)" > >>>> /> > >>>> > >>>> The docs seem to recommend adding a version field, which I haven't > >>>> done yet. I also choose "loaded" versus "fetch-group" because I hadn't > >>>> defined any custom fetch groups. > >>>> > >>>> With no offense intended towards the developers, I'm getting the > >>>> impression that OpenJPA is currently not the right choice for a GWT > >>>> project, until this particular issue is resolved. > >>>> > >>>> Jason > >>>> > >>>> > >>>> On Sat, Apr 9, 2011 at 7:43 AM, Rick Curtis <[email protected] > > > >>>> wrote: > >>>> > Jason - > >>>> > > >>>> >> Sorry if this is a frequently asked question. > >>>> > This isn't a frequent question... yet. It seems that this issue has > >>>> come > >>>> up > >>>> > a number of times on users/dev. There was a recent post[1] on a > >>>> similar > >>>> > issue that didn't end with much of a solution. Mike has had this > >>>> > detach/proxy business on his list of things he wanted to do for > quite > >>>> a > >>>> > time... :-) > >>>> > > >>>> > What version of OpenJPA are you running with? > >>>> > > >>>> > If you're running 2.0.0 or later and you're in need of a workaround > >>>> in > >>>> the > >>>> > short term.... and depending on how your application is structured, > >>>> enabling > >>>> > LiteAutoDetach[2] might get you by this problem. The only reason I'm > >>>> > suggesting this property as I know that it will remove all proxies > on > >>>> > EntityManager.close(). > >>>> > > >>>> > [1] http://openjpa.markmail.org/thread/sczpivhncne27co4 > >>>> > [2] > >>>> > > >>>> > http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_detach_state--- > >>>> > openjpa.DetachState=loaded(LiteAutoDetach=true) > >>>> > > >>>> > Thanks, > >>>> > Rick > >>>> > > >>>> > On Sat, Apr 9, 2011 at 6:55 AM, Jason Ferguson > >>>> <[email protected] > > >>> >wrote: > >>>> > > >>>> >> Sorry if this is a frequently asked question. > >>>> >> > >>>> >> I have an entity, Location, which has a bidirectional > >>>> >> OneToMany/ManyToOne relationship with another entity, BorderPoint. > >>>> >> Both entities implement Serializable and IsSerializable. > >>>> >> > >>>> >> The BorderPoint collection within the Location object is an > >>>> ArrayList. > >>>> >> Unfortunately, OpenJPA uses a proxy class which is not serializable > >>>> by > >>>> >> GWT. I've tried annotating both entities with > >>>> >> @DetachedState(enabled=true) with no luck. > >>>> >> > >>>> >> Can anyone assist? > >>>> >> > >>>> >> Jason > >>>> >> > >>>> > > >>>> > >>> > >>> > >> > > > > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/OpenJPA-and-GWT-Serialization-tp6256796p6311931.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >
