dpHibernate 2.0 code example

66 views
Skip to first unread message

pocketfuzzies

unread,
Mar 18, 2011, 12:33:21 PM3/18/11
to dpHibernate
Hi,

I know that dpHibernate 2.0 is still in development, but since
you're up to RC6, I was hoping that someone out there could provide an
example or documentation about how to use it? I've og the backend
set up properly (I think) from using the scattered documentation on
the project website, but I couldn't tell what bits applied to v1.xxx
of dpHibernate and what applied to v2.0. Where I'm having the most
trouble is on the flex/client side. (I'm a Spring/middle layer
developer really).

Specifically, I'm having the following issues

1. When I try to add "extends HibernateBean" to my AS value object,
and I add "import org.dphibernate.core.HibernateBean", the flex
compiler tells me that it can't find HibernateBean, and since I can't
look in the swc, I don't know what the correct import statement should
be.

2. How and where do I define a default HibernateService?

If an example isn't available, could someone please take a stab a
those two questions please? Thanks

Marty Pitt

unread,
Mar 18, 2011, 12:44:08 PM3/18/11
to dphib...@googlegroups.com
?Hi

Documentation relating to v2:
http://code.google.com/p/dphibernate/wiki/SetupAndConfigurationV2
http://ria.dzone.com/articles/lazy-loading-flex-blazeds-hibernate

Blog posts:
http://martypitt.wordpress.com/tag/dpHibernate/

Samples for v2:
http://code.google.com/p/dphibernate/source/browse/#svn%2Ftrunk%2Fsamples%2FlazyLoadingWithSpring
http://code.google.com/p/lazyoverflow/

Regarding your specific issues - sounds like the .swc isn't in your build
path correctly. The import you're using is correct. If you're using
FlashBuilder, go to your project, right click -> properties -> build path ->
Library Path, and ensure the dpHibernate flex project is there. (If not,
add it).

Note - FlashBuilder's package explorer lets you look at the classes inside a
swc.


Defining a default hibernate service - normally this is done in the client
at startup:
http://code.google.com/p/dphibernate/source/browse/trunk/samples/lazyLoadingWithSpring/flex/src/Pepper.mxml#58
protected function
onAppComplete(event:FlexEvent):void
{
// Setup a default service.
// This is used by beans to perform
dpHibernate operations (Save / Load, etc)
// where a service has not yet been assigned
to the bean.
HibernateManaged.defaultHibernateService=dataService;
loadData();
}

Examples of this service are documented here:
http://code.google.com/p/dphibernate/wiki/SetupAndConfigurationV2#Server_side_services

Regards,


Marty
--------------------------------------------------
From: "pocketfuzzies" <pocket...@gmail.com>
Sent: Friday, March 18, 2011 12:33 PM
To: "dpHibernate" <dphib...@googlegroups.com>
Subject: dpHibernate 2.0 code example

> --
> You received this message because you are subscribed to the Google Groups
> "dpHibernate" group.
> To post to this group, send email to dphib...@googlegroups.com.
> To unsubscribe from this group, send email to
> dphibernate...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/dphibernate?hl=en.
>
>

pocketfuzzies

unread,
Mar 18, 2011, 3:28:09 PM3/18/11
to dpHibernate
Thanks

I feel silly for asking the first question since the fix was a matter
of declaring the swc name correctly in the pom.xml file (I had
"dpHibernate-2.0RC6.swc" instead of "dpHibernate-2.0-RC6.swc". Now
of course, it compiles. The flex people on the project do use flex
builder plugin for eclipse, but since I'm a backend person, I don't
have a flex builder license, and can't use it. I'm just expected to
get lazy loading working and tell the flex developers what to add to/
how to modify the value objects.

I got one of the flex guys to add the default hibernate service to the
flex side. (I didn't know what the equivalent function in our code was
named).

Now, a new question - when I use long primitive types for my identity
attribute in my java entity classes I get

[BlazeDS]03/18/2011 14:53:10.691 [ERROR] [Endpoint.AMF] Exception
occurred during serialization:
org.springframework.core.convert.ConversionFailedException: Unable to
convert value "71" from type 'java.lang.Long' to type 'long'; nested
exception is java.lang.IllegalArgumentException: Could not convert
number [71] of type [java.lang.Long] to unknown target class [long]

But if I change them to type int (which is not preferred), I don't get
an error. Is this the issue that has posts in the groups saying it's a
known defect, or did I not set something up correctly?

Also, is it possible to get loog/debug messages for dpHibernate
through log4j? I tried adding a new appender for
org.dphibernate.core, but I didn't seem to get any output

I'm not getting my LazyLoad exception anymore, and the hibernate/
spring log messages say that it found my collections, so other than my
question about the long values, I think I'm set (hopefully).

I took it for a test drive, and I get the following error

On Mar 18, 12:44 pm, Marty Pitt <martyp...@me.com> wrote:
> ?Hi
>
> Documentation relating to v2:http://code.google.com/p/dphibernate/wiki/SetupAndConfigurationV2http://ria.dzone.com/articles/lazy-loading-flex-blazeds-hibernate
>
> Blog posts:http://martypitt.wordpress.com/tag/dpHibernate/
>
> Samples for v2:http://code.google.com/p/dphibernate/source/browse/#svn%2Ftrunk%2Fsam...http://code.google.com/p/lazyoverflow/
>
> Regarding your specific issues - sounds like the .swc isn't in your build
> path correctly.  The import you're using is correct.  If you're using
> FlashBuilder, go to your project, right click -> properties -> build path ->
> Library Path, and ensure the dpHibernate flex project is there.  (If not,
> add it).
>
> Note - FlashBuilder's package explorer lets you look at the classes inside a
> swc.
>
> Defining a default hibernate service - normally this is done in the client
> at startup:http://code.google.com/p/dphibernate/source/browse/trunk/samples/lazy...
>                         protected function
> onAppComplete(event:FlexEvent):void
>                         {
>                                 // Setup a default service.
>                                 // This is used by beans to perform
> dpHibernate operations (Save / Load, etc)
>                                 // where a service has not yet been assigned
> to the bean.
>                                 HibernateManaged.defaultHibernateService=dataService;
>                                 loadData();
>                         }
>
> Examples of this service are documented here:http://code.google.com/p/dphibernate/wiki/SetupAndConfigurationV2#Ser...
>
> Regards,
>
> Marty
> --------------------------------------------------
> From: "pocketfuzzies" <pocketfuzz...@gmail.com>

Marty Pitt

unread,
Mar 18, 2011, 3:43:04 PM3/18/11
to dphib...@googlegroups.com
?No problem re the swc-- I have a pathological hatred of maven, so I'm glad
to see it blamed for any problems. :)

Interesting issue regarding the primitives, that looks like a bug. I've
always used wrapper equviliants (eg., Long, instead of long), as doesn't
Hibernate just box the primitives during persistence? (Not sure where I
read that, I might have it wrong).

We've had a bunch of problems with handling long/Long, and bug fixes have
been committed, but it looks like there's still some bugs in there. Is
using java.lang.Long an option for your identity column?

I've filed a defect for this. Would you please update it with the full
stack trace. (Looks like Spring is throwing the exception there, not
dpHibernate - so it'd be good to understand the use case).
http://code.google.com/p/dphibernate/issues/detail?id=62

With regards to logging - nope, we've been pretty slack thus far in the
codebase, and haven't been using a standard logging framework - at least not
consistently. I've raised an enhancement for that, as we really should be
using SLF4j /log4J. That'll need to be post 2.0 however.
http://code.google.com/p/dphibernate/issues/detail?id=63

Thanks,

Marty

--------------------------------------------------
From: "pocketfuzzies" <pocket...@gmail.com>
Sent: Friday, March 18, 2011 3:28 PM
To: "dpHibernate" <dphib...@googlegroups.com>
Subject: Re: dpHibernate 2.0 code example

pocketfuzzies

unread,
Mar 21, 2011, 10:23:38 AM3/21/11
to dpHibernate
Marty,

Unfortunately, due to the environment I work in, I physically
can't copy and paste the stack trace. The internet and my work
environment are on two separate networks. I hand typed out that error,
hoping it would be enough to give you an idea of what's going on.
Sorry. It frustrates me that I can't give you everything you need to
help me.

On a side note, changing the long to Long or to int does not
solve the problem. I don't know how the issue disappeared on Friday,
but today it's back. Same message, just int can't be converted to
number instead. I'm going to search the Spring forums next, since
it's a spring class that throws the exception. I jus t thought it
might be related to dphibernate because before, hibernate and spring
interacted correctly. I just could do lazy loading.

Thanks

On Mar 18, 3:43 pm, Marty Pitt <martyp...@me.com> wrote:
> ?No problem  re the swc-- I have a pathological hatred of maven, so I'm glad
> to see it blamed for any problems.  :)
>
> Interesting issue regarding the primitives, that looks like a bug.  I've
> always used wrapper equviliants (eg., Long, instead of long), as doesn't
> Hibernate just box the primitives during persistence?  (Not sure where I
> read that, I might have it wrong).
>
> We've had a bunch of problems with handling long/Long, and bug fixes have
> been committed, but it looks like there's still some bugs in there.  Is
> using java.lang.Long an option for your identity column?
>
> I've filed a defect for this.  Would you please update it with the full
> stack trace.  (Looks like Spring is throwing the exception there, not
> dpHibernate - so it'd be good to understand the use case).http://code.google.com/p/dphibernate/issues/detail?id=62
>
> With regards to logging - nope, we've been pretty slack thus far in the
> codebase, and haven't been using a standard logging framework - at least not
> consistently.  I've raised an enhancement for that, as we really should be
> using SLF4j /log4J.  That'll need to be post 2.0 however.http://code.google.com/p/dphibernate/issues/detail?id=63
>
> Thanks,
>
> Marty
>
> --------------------------------------------------
> From: "pocketfuzzies" <pocketfuzz...@gmail.com>
> >> v2:http://code.google.com/p/dphibernate/wiki/SetupAndConfigurationV2http...

pocketfuzzies

unread,
Mar 21, 2011, 11:20:13 AM3/21/11
to dpHibernate
Just so you know, using the object Long instead of the primitive does
work... as long as it's used consistently through out your domain
objects (no pun intended). I found instances where getId() returned a
long even though the id attribute was declared as a Long, etc. Having
gone through all the entities and made every reference consistently of
type Long, I'm problem free.

Thanks again.
Reply all
Reply to author
Forward
0 new messages