Re: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-20 Thread Carlos Rovira

Hi Vineet,

I ' m using the following:

VOs in AS3  -> public var id:Number;

VOs in Java -> protected Integer id;

I'm using Oracle 9i as my RDBMS...but I think this shouldn't be the problem
as I'm using JPA/EJB3
and could change from one to another with four lines of configuration. The
problem is in FDS2 and the persistence layer.

btw, the glue between FDS2 and Hibernate is Spring.



On 1/19/07, Vineet Bhatia <[EMAIL PROTECTED]> wrote:


   Hi Carlos,

I have never had any problems with saving new entities using Hibernate and
FDS.
Are you using primitive int data-type by any chance? If so then change it
to Integer.
Which RDBMS are you using?

- vineet

On 1/19/07 1:03 PM, "Douglas McCarroll" <
[EMAIL PROTECTED]> wrote:





Well, it doesn't seem as though there's a great deal of actual use of
the FDMS/Hibernate option...

I'm struggling with trying to learn it, but there seem to be some bugs...

Hey flexcoders, is it possible that no one has attempted to create new
entities using FDMS/Hibernate?

Douglas

Carlos Rovira wrote:
>
> Thanks Douglas,
>
> Thanks for the response.
>
> In that case, how people deal with the fact that hibernate expect IDs
> with null value instead of 0?
> Or maybe I'm missing something?
>
>
>
>
> On 1/19/07, *Douglas McCarroll*
> <[EMAIL PROTECTED]

> <[EMAIL 
PROTECTED]:org.yahoo_primary.001%40douglasmccarroll.com>>> wrote:
>
> Hi Carlos,
>
> I can't be of much help but I can tell you...
>
> > Or maybe there's a way in FDS2 to configure default value to null?
>
> ... that you can probably forget this option. FDS converts null
> values
> to zero when it converts AS objects to Java objects, and the only
> workaround is to have code on the java side that converts zeros
> back to
> nulls. There are discussions about why this is the case in the
> archive
> if you want to do some searching...
>
> Douglas
>
> -
>
> Douglas McCarroll
>
> CairngormDocs.org Webmaster
> http://www.CairngormDocs.org 

>
> Flex Developer
> http://www.brightworks.com 

> 617.459.3840
>
> -
>
>
>
> Carlos Rovira wrote:
> >
> > Hi,
> >
> > I'm switching from Toplink to Hibernate using JPA/EJB3 and
> Annotations.
> > I'm facing a problem with this change due to the fact that when I
> try
> > to persist new entities Hibernate throws a
> > "PersistenceObjectException: Detached entity passed to persist".
> > Hibernate expects new entities with ID = NULL and my new entities
> > reach the hibernate layer with ID = 0.
> >
> > If I were using hibernate xml config files (hbm.xml) I could use
> > "unsaved-value = 0" (for each entity), but I'm using Annotations
and
> > there's no "unsaved-value" annotation to use.
> >
> > So, anyone reach this problem? How could I change the default
> > configuration in Hibernate so new entities with ID = 0 will be
> > considered as the default.
> >
> > Or maybe there's a way in FDS2 to configure default value to null?
> >
> > Thanks for any light on this :)
> >
> > C.
> >
> >
> >
> >
> > --
> > ::| Carlos Rovira
> > ::| http://www.carlosrovira.com 
<
> http://www.carlosrovira.com 

>
> > ::| http://www.madeinflex.com 
<
> http://www.madeinflex.com 

>
> >
> >
>
>
>
>
> --
> ::| Carlos Rovira
> ::| http://www.carlosrovira.com 

> ::| http://www.madeinflex.com 

>





  





--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com


Re: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-20 Thread Carlos Rovira

Hi Jeff,

That was my first attempt. just before the persist method I was doing "
p.setId(null)"

That was enough for simple objets but fails if with complex objects that
have a collection inside.
If I add a new item to that collection I must to iterate and make a
"setId(null" again.

For that reason I was trying to set a global hibernate var that changes that
behaviour from null to 0.

Toplink does not have this problem and is works better with FDS2, but the
only one problem is with exceptions. When an toplink throws an exception we
have huge stack trace and FDS2 ends with a "channel disconnected" error.
This seems to be an error with toplink essentials.

So with hibernate we have the id problems and with toplink the exception
problemvery frustrating :(



On 1/19/07, Jeff Vroom <[EMAIL PROTECTED]> wrote:


   FDS needs a way to indicate that "0" on the client side means null on
the server… unfortunately that did not make it in 2.0.1 but I have it on
my list for the next release.   One workaround for this would be to extend
the assembler and override the createItem method.  If the id is 0 in that
class, just set it to null in the Java object.  I assume the Java object has
an "Integer" rather than an "int" so this is possible.



Jeff


 --

*From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
Behalf Of *Carlos Rovira
*Sent:* Friday, January 19, 2007 1:23 AM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend
with id=0 ("unsaved-value" problem)



Hi,

I'm switching from Toplink to Hibernate using JPA/EJB3 and Annotations.
I'm facing a problem with this change due to the fact that when I try to
persist new entities Hibernate throws a "PersistenceObjectException:
Detached entity passed to persist". Hibernate expects new entities with ID =
NULL and my new entities reach the hibernate layer with ID = 0.

If I were using hibernate xml config files (hbm.xml) I could use
"unsaved-value = 0" (for each entity), but I'm using Annotations and there's
no "unsaved-value" annotation to use.

So, anyone reach this problem? How could I change the default
configuration in Hibernate so new entities with ID = 0 will be considered as
the default.

Or maybe there's a way in FDS2 to configure default value to null?

Thanks for any light on this :)

C.




--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com

 





--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com


RE: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-19 Thread Jeff Vroom
FDS needs a way to indicate that "0" on the client side means null on
the server... unfortunately that did not make it in 2.0.1 but I have it
on my list for the next release.   One workaround for this would be to
extend the assembler and override the createItem method.  If the id is 0
in that class, just set it to null in the Java object.  I assume the
Java object has an "Integer" rather than an "int" so this is possible.

 

Jeff

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Carlos Rovira
Sent: Friday, January 19, 2007 1:23 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend
with id=0 ("unsaved-value" problem)

 

Hi,

I'm switching from Toplink to Hibernate using JPA/EJB3 and Annotations.
I'm facing a problem with this change due to the fact that when I try to
persist new entities Hibernate throws a "PersistenceObjectException:
Detached entity passed to persist". Hibernate expects new entities with
ID = NULL and my new entities reach the hibernate layer with ID = 0. 

If I were using hibernate xml config files (hbm.xml) I could use
"unsaved-value = 0" (for each entity), but I'm using Annotations and
there's no "unsaved-value" annotation to use.

So, anyone reach this problem? How could I change the default
configuration in Hibernate so new entities with ID = 0 will be
considered as the default.

Or maybe there's a way in FDS2 to configure default value to null? 

Thanks for any light on this :)

C.




-- 
::| Carlos Rovira
::| http://www.carlosrovira.com  
::| http://www.madeinflex.com   

 



Re: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-19 Thread Vineet Bhatia
Hi Carlos,

I have never had any problems with saving new entities using Hibernate and
FDS. 
Are you using primitive int data-type by any chance? If so then change it to
Integer.
Which RDBMS are you using?

- vineet

On 1/19/07 1:03 PM, "Douglas McCarroll"
<[EMAIL PROTECTED]> wrote:

>  
>  
>  
> 
> Well, it doesn't seem as though there's a great deal of actual use of
> the FDMS/Hibernate option...
> 
> I'm struggling with trying to learn it, but there seem to be some bugs...
> 
> Hey flexcoders, is it possible that no one has attempted to create new
> entities using FDMS/Hibernate?
> 
> Douglas
> 
> Carlos Rovira wrote:
>> >
>> > Thanks Douglas,
>> >
>> > Thanks for the response.
>> >
>> > In that case, how people deal with the fact that hibernate expect IDs
>> > with null value instead of 0?
>> > Or maybe I'm missing something?
>> >
>> >
>> >
>> >
>> > On 1/19/07, *Douglas McCarroll*
>> > <[EMAIL PROTECTED]
>> 
>> > > 
>>   >> wrote:
>> >
>> > Hi Carlos,
>> >
>> > I can't be of much help but I can tell you...
>> >
>>> > > Or maybe there's a way in FDS2 to configure default value to null?
>> >
>> > ... that you can probably forget this option. FDS converts null
>> > values
>> > to zero when it converts AS objects to Java objects, and the only
>> > workaround is to have code on the java side that converts zeros
>> > back to
>> > nulls. There are discussions about why this is the case in the
>> > archive
>> > if you want to do some searching...
>> >
>> > Douglas
>> >
>> > -
>> >
>> > Douglas McCarroll
>> >
>> > CairngormDocs.org Webmaster
>> > http://www.CairngormDocs.org 
>> >
>> > Flex Developer
>> > http://www.brightworks.com 
>> > 617.459.3840
>> >
>> > -
>> >
>> >
>> >
>> > Carlos Rovira wrote:
>>> > >
>>> > > Hi,
>>> > >
>>> > > I'm switching from Toplink to Hibernate using JPA/EJB3 and
>> > Annotations.
>>> > > I'm facing a problem with this change due to the fact that when I
>> > try
>>> > > to persist new entities Hibernate throws a
>>> > > "PersistenceObjectException: Detached entity passed to persist".
>>> > > Hibernate expects new entities with ID = NULL and my new entities
>>> > > reach the hibernate layer with ID = 0.
>>> > >
>>> > > If I were using hibernate xml config files (hbm.xml) I could use
>>> > > "unsaved-value = 0" (for each entity), but I'm using Annotations and
>>> > > there's no "unsaved-value" annotation to use.
>>> > >
>>> > > So, anyone reach this problem? How could I change the default
>>> > > configuration in Hibernate so new entities with ID = 0 will be
>>> > > considered as the default.
>>> > >
>>> > > Or maybe there's a way in FDS2 to configure default value to null?
>>> > >
>>> > > Thanks for any light on this :)
>>> > >
>>> > > C.
>>> > >
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > ::| Carlos Rovira
>>> > > ::| http://www.carlosrovira.com  <
>> > http://www.carlosrovira.com >
>>> > > ::| http://www.madeinflex.com  <
>> > http://www.madeinflex.com >
>>> > >
>>> > >
>> >
>> >
>> >
>> >
>> > -- 
>> > ::| Carlos Rovira
>> > ::| http://www.carlosrovira.com 
>> > ::| http://www.madeinflex.com 
>> >  
> 
>  
> 




Re: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-19 Thread Douglas McCarroll
Well, it doesn't seem as though there's a great deal of actual use of 
the FDMS/Hibernate option...

I'm struggling with trying to learn it, but there seem to be some bugs...

Hey flexcoders, is it possible that no one has attempted to create new 
entities using FDMS/Hibernate?

Douglas




Carlos Rovira wrote:
>
> Thanks Douglas,
>
> Thanks for the response.
>
> In that case, how people deal with the fact that hibernate expect IDs 
> with null value instead of 0?
> Or maybe I'm missing something?
>
>
>
>
> On 1/19/07, *Douglas McCarroll* 
> <[EMAIL PROTECTED] 
> > wrote:
>
> Hi Carlos,
>
> I can't be of much help but I can tell you...
>
> > Or maybe there's a way in FDS2 to configure default value to null?
>
> ... that you can probably forget this option. FDS converts null
> values
> to zero when it converts AS objects to Java objects, and the only
> workaround is to have code on the java side that converts zeros
> back to
> nulls. There are discussions about why this is the case in the
> archive
> if you want to do some searching...
>
> Douglas
>
> -
>
> Douglas McCarroll
>
> CairngormDocs.org Webmaster
> http://www.CairngormDocs.org 
>
> Flex Developer
> http://www.brightworks.com 
> 617.459.3840
>
> -
>
>
>
> Carlos Rovira wrote:
> >
> > Hi,
> >
> > I'm switching from Toplink to Hibernate using JPA/EJB3 and
> Annotations.
> > I'm facing a problem with this change due to the fact that when I
> try
> > to persist new entities Hibernate throws a
> > "PersistenceObjectException: Detached entity passed to persist".
> > Hibernate expects new entities with ID = NULL and my new entities
> > reach the hibernate layer with ID = 0.
> >
> > If I were using hibernate xml config files (hbm.xml) I could use
> > "unsaved-value = 0" (for each entity), but I'm using Annotations and
> > there's no "unsaved-value" annotation to use.
> >
> > So, anyone reach this problem? How could I change the default
> > configuration in Hibernate so new entities with ID = 0 will be
> > considered as the default.
> >
> > Or maybe there's a way in FDS2 to configure default value to null?
> >
> > Thanks for any light on this :)
> >
> > C.
> >
> >
> >
> >
> > --
> > ::| Carlos Rovira
> > ::| http://www.carlosrovira.com  <
> http://www.carlosrovira.com >
> > ::| http://www.madeinflex.com  <
> http://www.madeinflex.com >
> >
> >
>
>
>
>
> -- 
> ::| Carlos Rovira
> ::| http://www.carlosrovira.com 
> ::| http://www.madeinflex.com 
>  



Re: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-19 Thread Carlos Rovira

Thanks Douglas,

Thanks for the response.

In that case, how people deal with the fact that hibernate expect IDs with
null value instead of 0?
Or maybe I'm missing something?




On 1/19/07, Douglas McCarroll <[EMAIL PROTECTED]>
wrote:


  Hi Carlos,

I can't be of much help but I can tell you...

> Or maybe there's a way in FDS2 to configure default value to null?

... that you can probably forget this option. FDS converts null values
to zero when it converts AS objects to Java objects, and the only
workaround is to have code on the java side that converts zeros back to
nulls. There are discussions about why this is the case in the archive
if you want to do some searching...

Douglas

-

Douglas McCarroll

CairngormDocs.org Webmaster
http://www.CairngormDocs.org

Flex Developer
http://www.brightworks.com
617.459.3840

-


Carlos Rovira wrote:
>
> Hi,
>
> I'm switching from Toplink to Hibernate using JPA/EJB3 and Annotations.
> I'm facing a problem with this change due to the fact that when I try
> to persist new entities Hibernate throws a
> "PersistenceObjectException: Detached entity passed to persist".
> Hibernate expects new entities with ID = NULL and my new entities
> reach the hibernate layer with ID = 0.
>
> If I were using hibernate xml config files (hbm.xml) I could use
> "unsaved-value = 0" (for each entity), but I'm using Annotations and
> there's no "unsaved-value" annotation to use.
>
> So, anyone reach this problem? How could I change the default
> configuration in Hibernate so new entities with ID = 0 will be
> considered as the default.
>
> Or maybe there's a way in FDS2 to configure default value to null?
>
> Thanks for any light on this :)
>
> C.
>
>
>
>
> --
> ::| Carlos Rovira
> ::| http://www.carlosrovira.com 
> ::| http://www.madeinflex.com 
>
>

 





--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com


Re: [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend with id=0 ("unsaved-value" problem)

2007-01-19 Thread Douglas McCarroll
Hi Carlos,

I can't be of much help but I can tell you...

 > Or maybe there's a way in FDS2 to configure default value to null?

... that you can probably forget this option. FDS converts null values 
to zero when it converts AS objects to Java objects, and the only 
workaround is to have code on the java side that converts zeros back to 
nulls. There are discussions about why this is the case in the archive 
if you want to do some searching...


Douglas


-

Douglas McCarroll

CairngormDocs.org Webmaster
http://www.CairngormDocs.org

Flex Developer
http://www.brightworks.com
617.459.3840

-





Carlos Rovira wrote:
>
> Hi,
>
> I'm switching from Toplink to Hibernate using JPA/EJB3 and Annotations.
> I'm facing a problem with this change due to the fact that when I try 
> to persist new entities Hibernate throws a 
> "PersistenceObjectException: Detached entity passed to persist". 
> Hibernate expects new entities with ID = NULL and my new entities 
> reach the hibernate layer with ID = 0.
>
> If I were using hibernate xml config files (hbm.xml) I could use 
> "unsaved-value = 0" (for each entity), but I'm using Annotations and 
> there's no "unsaved-value" annotation to use.
>
> So, anyone reach this problem? How could I change the default 
> configuration in Hibernate so new entities with ID = 0 will be 
> considered as the default.
>
> Or maybe there's a way in FDS2 to configure default value to null?
>
> Thanks for any light on this :)
>
> C.
>
>
>
>
> -- 
> ::| Carlos Rovira
> ::| http://www.carlosrovira.com 
> ::| http://www.madeinflex.com 
>
>