The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

bpetro (5) [Avatar] Offline
#1
I'm at the stage where I'm trying to bring in the project's pojo classes (and beans for accessing them) and access these via the servlet ... I think it'll be doable - I've already wrestled through the issues with the eclipse plugin not handling things right, and I have an ant script building the project except for issues I'm starting to see with GWT not certain what to do with seemingly innocent issues like developers putting logging (for debugging) into the classes. What are my options - I have no intention of using the logging on the client. Is there anyway to allow the server side to have their logging but cut it out for the Java -> JS compilations?

Thoughts?

PS: if this is going to be a nightmare - what are the best practices for providing data (EG: Server POJOs) via servlet w/o hitting server code incompatibilities? By best practices I mean when removing offending code is not an option - I mean ways around this if the project demands that the other team be able to have their debugging code.

THANKS!
robert.hanson (173) [Avatar] Offline
#2
Re: Trying to use Project's server pojo's
> Is there anyway to allow the server side to have their logging
> but cut it out for the Java -> JS compilations?

In code that only lives on the server (like the servlet), you can use whatever you want. Log4J, commons-logging, etc.

If the same code is shared between both the client and the server, like a model objects being passes between the client and the server, then you can't put logging in it unless you have two sets of objects (one for the client, and one for the server, using dozer or some other tool to copy data between them).
bpetro (5) [Avatar] Offline
#3
Re: Trying to use Project's server pojo's
Thanks Robert - that's what I've come to the conclusion of... we've isolated the POJOs pretty well and removed the logging from them. Just for everyone's future reference... a related question:

I assume GWT will ignore all sorts of hibernate annotations, correct? It appears in my early testing that this is true so I think we're in pretty darn good shape here...

We do have one concern - have you run into this one? The super class of all these hibernate POJOs has one statement that we've had to comment out for the moment... do you know a workaround on this?
-------------------------------------
public void initialize() {
Hibernate.initialize(this);
}
-------------------------------------
I am told this really should be uncommented for performance needs before we get into final stages of development. ... any ideas or thoughts on this?

THANKS!
bpetro (5) [Avatar] Offline
#4
Re: Trying to use Project's server pojo's
Thanks Robert - that's the same conclusion I came to ... we've isolated the POJOs pretty well and removed the logging from them. Just for everyone's future reference... a related question:

I assume GWT will ignore all sorts of hibernate annotations, correct? It appears in my early testing that this is true so I think we're in pretty darn good shape here...

We do have one concern - have you run into this one? The super class of all these hibernate POJOs has one statement that we've had to comment out for the moment... do you know a workaround on this?
-------------------------------------
public void initialize() {
Hibernate.initialize(this);
}
-------------------------------------
I am told this really should be uncommented for performance needs before we get into final stages of development. ... any ideas or thoughts on this?

THANKS!
robert.hanson (173) [Avatar] Offline
#5
Re: Trying to use Project's server pojo's
> Hibernate.initialize(this);

Nothing you can do about this... Unless you write a second version of this class that does nothing, and include that in the GWT compilation. This won't work exactly right if you have to have both the real Hibernate and the fake Hibernate in the classpath at the same time though... but in that case you can look at how GWT compiles in JDK classes (if I knew how to do this I have forgotten, so you might want to search the GWT dev list)

I am not exactly sure why you need this though. All it does is initialize the proxy object. Another way of doing that same thing is to not allow lazy loading of the class properties. In fact it is probably faster that way.

So if object X has properties A,B,C,D and A,B are lazy it might look like this...

Fetch from DB: loads fields C,D
Hibernate.initialize: loads fields A,B

But if object X has properties A,B,C,D and none are lazy...

Fetch from DB: loads fields A,B,C,D

You end up saving yourself at least one DB call. You can test that by turning on logging to see what queries are generated by Hibernate.