Hi Gul, On Nov 22, 2007, at 10:18 AM, Gul Onural wrote:
Sorry, I should have said GregorianCalendar. What we do in our product is that we retrieve the objects from the database through JPA, and construct another set of objects(business objects) from these JPA objects. So, our JPA objects are not directlypassed to the business logic layer. At the time the business objects are used the JPA objects are already detached and context closed. Therefore when we want to do anything with the Calendar that we retrieved throughJPA, the openjpa gives us an exception saying context closed.
This is probably a bug. Once the Calendar instance is detached, it should behave normally, just like a new instance of GregorianCalendar (it should implement all of the behavior of GregorianCalendar). If you have a small reproducible test case, please file a JIRA.
May be better thing to do was to clone the Calendar JPA returns and pass this clone as our business object to the other layers of the product.
I'd hate to see you go through all this trouble if we can make the OpenJPA Calendar do what you need it to do.
Craig
Gul -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, November 22, 2007 1:08 PM To: [email protected] Subject: Re: Calendar problem in openjpa Hi Gul, The abstract class Calendar doesn't have a concrete add method either. It's the GregorianCalendar that implements the abstract method. Are you saying you want a GregorianCalendar as the field type of your persistent Calendar? Have you tried declaring that as the field type? And why don't you want the openjpa implementation of Calendar? Regards, Craig On Nov 22, 2007, at 9:44 AM, Gul Onural wrote:We discovered a strange behavior about the usage of Calendar and I waswondering if this was expected : There is a Calendar field in one of our JPA objects. If I try to use this field through its getter method, the instance I got back is the open jpa implementation of the Calendar interface, not Sun implementation (i.e. not java.util.Calendar). We discovered this when we try to call "add" on this implementation which openjpaimplementation doesn't support. We obviously do not want t use openjpaimplementation of the Calendar in our code. I was wondering if it is the right behavior ? Shouldn't openjpa give java.util.Calendar back when it unserializes the Calendar field ? GulCraig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
