You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jan Torben Heuer <jt...@mail2003.dnsalias.org> on 2007/07/31 13:20:44 UTC

object oriented persistence layer?

Hi,

can someony suggest me a persistence soloution for xmlbeans objects? I'd
like to use db4o, but I only found posts of people who had problems with
xmlbeans and db4o together.

Id' like to use some kind of embedded soloution rather than an
object-to-RDBMS converter.


Thanks, 

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: object oriented persistence layer?

Posted by pricone <ra...@yahoo.ca>.


pricone wrote:
> 
> 
>  I got what the problem is . At load ,when XmlObject classes invoke the
> setter methods ,they create new Objects ,do not keep the reference .This
> is a huge problem !!! So an XmlObject is created once with the constructor
> from the interceptor and when it's set to a former XmlObject which holds
> it ,XmlBeans creates again a new instance . I hope you got my point . The
> Interceptor works perfect .Have you always solved this problem ? Thanks
> ,Razvan
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/object-oriented-persistence-layer--tf4192422.html#a12289467
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: object oriented persistence layer?

Posted by pricone <ra...@yahoo.ca>.


Razvan Prichici wrote:
> 
> 
> Here is my interceptor :
> 
>  public Object instantiate(String entityName, EntityMode entityMode,
> Serializable id) 
>   throws CallbackException {
> 
>     Object returnObject=null;
> 
>     try {
>       _classReflector=new ClassReflector(entityName);
>     } catch (ReflectionException e) {
>       if (_logger.isDebugEnabled()) {
>         _logger.error(e.getMessage());
>       }
>     }
> 
> 
>     if(_classReflector.implementsOrExtends(XmlObject.class)) 
>     {
>     
>     
>       if (_logger.isDebugEnabled()) {
>         _logger.debug("Start overriding default constructor");
>       }
>       try {
>         _innerClassReflector=new ClassReflector(
>             new ClassReflector(_classReflector.getDefaultInterface())
>             .getInnerClass(FACTORY_CLASS));
>         returnObject =
> _innerClassReflector.invokeStaticMethod(FACTORY_NEW_INSTANCE);
>       } catch (ReflectionException e) {
>         if (_logger.isDebugEnabled()) {
>           _logger.error(e.getMessage());
>         }
>       }
> 
>       ((Persistable)returnObject).setPersistentId(id);
>      
> 
>       if (_logger.isDebugEnabled()) {
>         _logger.debug("End overriding default constructor");
>       }
>       return returnObject ;
> 
> else ... default ..
> 
> 
> 
> 
> ClassReflector is a helper class ,nothing special ..
> 
>  public ClassReflector( String aClassName ) throws ReflectionException {
>     try {
>       _class = Class.forName( aClassName );
>     } catch ( ClassNotFoundException e ) {
>       throw new ReflectionException( "Class not found: "
>           + aClassName, e );
>     }
>   }
> 
>   /**
>    * Constructs the object.
>    * 
>    * @param aClass
>    *            Class to do reflection on.
>    */
>   public ClassReflector( Class aClass ) {
>     _class = aClass;
>   }
> 
>   /**
>    * Gets the class object. 
>    */
>   public Class getClassObject() {
>     return _class; 
>   }
> 
>   /**
>    * Constructs a default instance of the class and verifies it implements
> a
>    * specified interface.
>    * 
>    * @param aRequiredInterface
>    *            Interface that must be implemented by the object.
>    * @return Object.
>    * @throws ReflectionException
>    *             In case the object cannot be constructed or does not
>    *             implement the required interface.
>    */
>   public Object constructDefaultObject( Class aRequiredInterface )
>   throws ReflectionException {
>     if ( !aRequiredInterface.isAssignableFrom( _class ) ) {
>       throw new ReflectionException( "Class '" + _class.getName( )
>           + "' does not implement the required interface '"
>           + aRequiredInterface.getName( ) + "'" );
>     }
>     return constructDefaultObject( );
>   }
> 
>   /**
>    * Constructs a default instance of the class. This also works if the
>    * constructor is private.
>    * 
>    * @return Constructed object.
>    * @throws ReflectionException
>    *             In case the object cannot be constructed.
>    */
>   public Object constructDefaultObject( ) throws ReflectionException {
>     try {
>       try {
>         Constructor constructor = _class
>         .getDeclaredConstructor( new Class[0] );
>         constructor.setAccessible( true ); // allow access to private
>         // constructor.
> 
>         return constructor.newInstance( new Object[0] );
>       } catch ( NoSuchMethodException e ) {
>         // Use default no-arg constructor.
>         return _class.newInstance( );
>       }
>     } catch ( InvocationTargetException e ) {
>       throw new ReflectionException( e.getMessage( ), e );
>     } catch ( InstantiationException e ) {
>       throw new ReflectionException( e.getMessage( ), e );
>     } catch ( IllegalAccessException e ) {
>       throw new ReflectionException( e.getMessage( ), e );
>     }
>   }
> 
>   /**
>    * Determines if the class implements or extends another class.
>    * 
>    * @param aSuperClass
>    *            Super class.
>    * @return True if the class implements or extends the other class.
>    */
>   public boolean implementsOrExtends( Class aSuperClass ) {
>     return aSuperClass.isAssignableFrom( _class );
>   }
> 
>   
>   public Object invokeStaticMethod(String aMethodName) throws
> ReflectionException
>   {
>    
>       try {
>         Method m = _class.getMethod(aMethodName, new Class[] {} );
>         return m.invoke(null,null);
>       } catch (SecurityException e) {
>         throw new ReflectionException( e.getMessage( ), e );
>       } catch (IllegalArgumentException e) {
>         throw new ReflectionException( e.getMessage( ), e );
>       } catch (NoSuchMethodException e) {
>         throw new ReflectionException( e.getMessage( ), e );
>       } catch (IllegalAccessException e) {
>         throw new ReflectionException( e.getMessage( ), e );
>       } catch (InvocationTargetException e) {
>         throw new ReflectionException( e.getMessage( ), e );
>       }
>    
>   }
>   
>   /**
>    * Gets the first interface implemented by the class . 
>   
>    * @throws ReflectionException
>    *             In case the class does not implement any interface.
>    */
>   public Class getDefaultInterface() throws ReflectionException
>   {
>     try {
>       return _class.getInterfaces()[0];
>     } catch (RuntimeException e) {
>       throw new ReflectionException( "Class does not implement any
> interface  "
>         , e );
>     }
>   }
>   
>   /**
>    * Gets the inner class object. 
>    * @param aInnerClassName
>    *            inner class name.
>    * @throws ReflectionException
>    *             In case the inner class cannot be found.
>    */
>   public Class getInnerClass(String aInnerClassName) throws
> ReflectionException
>   {
>     try {
>       return Class.forName(_class.getName()+"$"+aInnerClassName);
>     } catch (ClassNotFoundException e) {
>       throw new ReflectionException( "Class not found: "
>           + _class.getName()+"$"+aInnerClassName, e );
>     }
>   }
> 
> 
>   The problem is when I tried to load this XmlObject bastards. To load a
> single object is OK ,but trying to load a Object which has one-to-many
> relations with another object and so on .. . It fails .It throws
> NonUniqueObjectException at load . It's trying to flush the session
> immediatly after load and it finds dirty ,I don't know ,but it sucks .
> 
> 

-- 
View this message in context: http://www.nabble.com/object-oriented-persistence-layer--tf4192422.html#a12271017
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: object oriented persistence layer?

Posted by Gustavo Aquino <aq...@gmail.com>.
Razvan,

Sorry for long time.... the work has killing me :D

I will send how i use hibernate with xmlbeans, i dont have time to write
papper now, but i will.

Can you send me your Hibernate interceptor ? this will help me to see the
problem and i will try to help you.

best regards.

On 8/8/07, pricone <ra...@yahoo.ca> wrote:
>
>
>
>
> Razvan Paul wrote:
> >
> > Hi ,
> >
> > I use Interceptor to instantiate a Entity without Default Constructor
> too,
> > but I have a little problem on loading XmkObject objects. It recognizes
> > them as being detached instead of persistent and it throws an exception
> > like duplicate
> > instances with the same id .Please tell me what I miss .I have only
> > overriden the instanciate method from interceptor ,the rest I left
> default
> > . I did a little debugging and I found out that it does not create the
> > EntityEntry for my XmkObject objects . Can you help me ,please :) .Could
> > you send me your source or tell me if you had the same problem ?
> >
>
> --
> View this message in context:
> http://www.nabble.com/object-oriented-persistence-layer--tf4192422.html#a12061382
> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

Re: object oriented persistence layer?

Posted by pricone <ra...@yahoo.ca>.


Razvan Paul wrote:
> 
> Hi ,
> 
> I use Interceptor to instantiate a Entity without Default Constructor too,
> but I have a little problem on loading XmkObject objects. It recognizes
> them as being detached instead of persistent and it throws an exception
> like duplicate 
> instances with the same id .Please tell me what I miss .I have only
> overriden the instanciate method from interceptor ,the rest I left default
> . I did a little debugging and I found out that it does not create the
> EntityEntry for my XmkObject objects . Can you help me ,please :) .Could
> you send me your source or tell me if you had the same problem ? 
> 

-- 
View this message in context: http://www.nabble.com/object-oriented-persistence-layer--tf4192422.html#a12061382
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: object oriented persistence layer?

Posted by Cezar Andrei <ce...@bea.com>.
It would be great to have a sample; I'm sure many of the people watching
this list would greatly appreciate it.

 

Cezar

 

________________________________

From: Gustavo Aquino [mailto:aquino.gustavo@gmail.com] 
Sent: Tuesday, July 31, 2007 1:32 PM
To: user@xmlbeans.apache.org
Subject: Re: object oriented persistence layer?

 

Hi Cezar,

I use Interceptor to instantiate a Entity without Default Constructor,
in relationship n-n or 1-n  to populate a array of XMLBeans and not
PersistSet of Hibernate and to return a appropriate instance of object
that implements a  interface mapped  in .hbm. Because XMLBeans use
Factory in interface to create a new instance, and hibernate use a
default constructor to create a new instance. 

I set class attribute of my .hbm.xml  to interface (XMLObject), and
interceptor return a instance of object that hibernate  will used do
populate or get attributes.

I can send a sample or my framework tonight , here i don't have the
source code, if you want. 

This solution is part of a ESB and framework created to attend a client.
The same object (XMLObject) is used in n layers, persistence, domain,
service, and interface.

When decided to use XMLBeans in project, i had very problems to use him
in persistence tier,  and  used Xmlbeans with DTO unique in service
layer, need more work of programmers, using interceptor we optimized
work with a good performance. I'm writing a papper about this solutions,
but doesn't have time to finalize him. 

Best regards.

Gustavo Aquino

On 7/31/07, Cezar Andrei <ce...@bea.com> wrote:

Gustavo,

 

Can you tell us a little more about your solution, maybe show us a
little bit of the interceptor?

 

Thanks,

Cezar

 

________________________________

From: Gustavo Aquino [mailto:aquino.gustavo@gmail.com] 
Sent: Tuesday, July 31, 2007 11:29 AM
To: user@xmlbeans.apache.org
Subject: Re: object oriented persistence layer?

 

Hi Jan,

I use Hibernate to persist my xmlObjets, to do xmlbeans and hibernate
work together i create one hibernate interceptor.

best regards.



On 7/31/07, Jan Torben Heuer <jt...@mail2003.dnsalias.org> wrote:

Hi,

can someony suggest me a persistence soloution for xmlbeans objects? I'd
like to use db4o, but I only found posts of people who had problems with
xmlbeans and db4o together.

Id' like to use some kind of embedded soloution rather than an 
object-to-RDBMS converter.


Thanks,

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

 


Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated
entities, that may be confidential, proprietary, copyrighted and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

 


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

Re: object oriented persistence layer?

Posted by Gustavo Aquino <aq...@gmail.com>.
Hi Cezar,

I use Interceptor to instantiate a Entity without Default Constructor, in
relationship n-n or 1-n  to populate a array of XMLBeans and not PersistSet
of Hibernate and to return a appropriate instance of object  that implements
a  interface mapped  in .hbm. Because XMLBeans use Factory in interface to
create a new instance, and hibernate use a default constructor to create a
new instance.

I set class attribute of my .hbm.xml  to interface (XMLObject), and
interceptor return a instance of object that hibernate  will used do
populate or get attributes.

I can send a sample or my framework tonight , here i don't have the source
code, if you want.

This solution is part of a ESB and framework created to attend a client. The
same object (XMLObject) is used in n layers, persistence, domain, service,
and interface.

When decided to use XMLBeans in project, i had very problems to use him in
persistence tier,  and  used Xmlbeans with DTO unique in service layer, need
more work of programmers, using interceptor we optimized work with a good
performance. I'm writing a papper about this solutions, but doesn't have
time to finalize him.

Best regards.

Gustavo Aquino

On 7/31/07, Cezar Andrei <ce...@bea.com> wrote:
>
>  Gustavo,
>
>
>
> Can you tell us a little more about your solution, maybe show us a little
> bit of the interceptor?
>
>
>
> Thanks,
>
> Cezar
>
>
>   ------------------------------
>
> *From:* Gustavo Aquino [mailto:aquino.gustavo@gmail.com]
> *Sent:* Tuesday, July 31, 2007 11:29 AM
> *To:* user@xmlbeans.apache.org
> *Subject:* Re: object oriented persistence layer?
>
>
>
> Hi Jan,
>
> I use Hibernate to persist my xmlObjets, to do xmlbeans and hibernate work
> together i create one hibernate interceptor.
>
> best regards.
>
>
>  On 7/31/07, *Jan Torben Heuer* <jt...@mail2003.dnsalias.org> wrote:
>
> Hi,
>
> can someony suggest me a persistence soloution for xmlbeans objects? I'd
> like to use db4o, but I only found posts of people who had problems with
> xmlbeans and db4o together.
>
> Id' like to use some kind of embedded soloution rather than an
> object-to-RDBMS converter.
>
>
> Thanks,
>
> Jan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>
>
> Notice: This email message, together with any attachments, may contain
> information of BEA Systems, Inc., its subsidiaries and affiliated entities,
> that may be confidential, proprietary, copyrighted and/or legally
> privileged, and is intended solely for the use of the individual or entity
> named in this message. If you are not the intended recipient, and have
> received this message in error, please immediately return this by email and
> then delete it.

Re: object oriented persistence layer?

Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
Stefan Offermann wrote:


> What so you exactly mean with "embedded solution"?

embedded databases can by started out of the java-program itself. So an
external database is not needed.

Can be very useful for developers and end-users ;-)
-> http://db4o.com


Jan



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: object oriented persistence layer?

Posted by Stefan Offermann <of...@uni-muenster.de>.
Hi JT!

Jan Torben Heuer schrieb:
>>I use Hibernate to persist my xmlObjets, to do xmlbeans and hibernate work
>>together i create one hibernate interceptor.
> 
> I never uses hibernate, but it is build on top of a Relational DBMS like
> postgresql, isn't it?

Yes, it it used to save the state of an object to a database (and vice 
versa), also known as object-relational-mapping.

>>>Id' like to use some kind of embedded soloution rather than an
>>>object-to-RDBMS converter.

What so you exactly mean with "embedded solution"?

Best regars,
Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: object oriented persistence layer?

Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
Gustavo Aquino wrote:

> Hi Jan,
> 
> I use Hibernate to persist my xmlObjets, to do xmlbeans and hibernate work
> together i create one hibernate interceptor.
I never uses hibernate, but it is build on top of a Relational DBMS like
postgresql, isn't it?

>> Id' like to use some kind of embedded soloution rather than an
>> object-to-RDBMS converter.

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: object oriented persistence layer?

Posted by Cezar Andrei <ce...@bea.com>.
Gustavo,

 

Can you tell us a little more about your solution, maybe show us a
little bit of the interceptor?

 

Thanks,

Cezar

 

________________________________

From: Gustavo Aquino [mailto:aquino.gustavo@gmail.com] 
Sent: Tuesday, July 31, 2007 11:29 AM
To: user@xmlbeans.apache.org
Subject: Re: object oriented persistence layer?

 

Hi Jan,

I use Hibernate to persist my xmlObjets, to do xmlbeans and hibernate
work together i create one hibernate interceptor.

best regards.




On 7/31/07, Jan Torben Heuer <jt...@mail2003.dnsalias.org> wrote:

Hi,

can someony suggest me a persistence soloution for xmlbeans objects? I'd
like to use db4o, but I only found posts of people who had problems with
xmlbeans and db4o together.

Id' like to use some kind of embedded soloution rather than an 
object-to-RDBMS converter.


Thanks,

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

 


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

Re: object oriented persistence layer?

Posted by Gustavo Aquino <aq...@gmail.com>.
Hi Jan,

I use Hibernate to persist my xmlObjets, to do xmlbeans and hibernate work
together i create one hibernate interceptor.

best regards.



On 7/31/07, Jan Torben Heuer <jt...@mail2003.dnsalias.org> wrote:
>
> Hi,
>
> can someony suggest me a persistence soloution for xmlbeans objects? I'd
> like to use db4o, but I only found posts of people who had problems with
> xmlbeans and db4o together.
>
> Id' like to use some kind of embedded soloution rather than an
> object-to-RDBMS converter.
>
>
> Thanks,
>
> Jan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

Re: object oriented persistence layer?

Posted by Fermin Da Costa Gomez <da...@gmail.com>.
Have a look at Perst.
Never tried it with XmlBeans but i have been using it for many other things
in the past.

GL,

Fermin DCG

On 31/07/07, Jan Torben Heuer <jt...@mail2003.dnsalias.org> wrote:
>
> Hi,
>
> can someony suggest me a persistence soloution for xmlbeans objects? I'd
> like to use db4o, but I only found posts of people who had problems with
> xmlbeans and db4o together.
>
> Id' like to use some kind of embedded soloution rather than an
> object-to-RDBMS converter.
>
>
> Thanks,
>
> Jan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>


-- 
"The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man."
- George Bernard Shaw (1856 - 1950)