[Hibernate] Unit Testing With ThreadLocal Sessions

2003-08-06 Thread Matthew E . Porter
Greetings.  I am interested in hearing how people unit test method that 
call session.save(), update(), and delete() when the session is 
provided via the ThreadLocal pattern.  For me, the primary question is 
whether or not the method containing the session method calls actually 
closes the database connection (session.close()) or is it called after 
returning from the tested method.  From a pure unit testing 
stand-point, it would seem that it would be desired to be called inside 
the tested method.

For a project I am working on, we devised a solution (aka hack) to 
solve this.  A new Session interface implementation was created that 
wraps an internal Session object as normally provided.  Yet, we added 2 
methods: suspendClose() and unsuspendClose().  When closes are suspend, 
the connection is NOT closed despite being called.  Specifically, it 
does not call session.close() on the internal Session object.

When a Session is retrieved, the closes are automatically suspended.  
The servlet filter unsuspends the close and closes the session if 
necessary at the end of the request.

Is this a hack?  Yes.  Does it work?  Yes.  Do we get the benefits of a 
ThreadLocal session?  Yes.  Can it be confusing to newbies who expect 
close to actual close the session?  Yes, but it only has this behavior 
during deployment.

Any thoughts and comments are welcome.

Cheers,
  matthew


---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Unit Testing With ThreadLocal Sessions

2003-08-09 Thread Matthew E . Porter
My only concern with this is that the business logic component is now  
coupled with the web tier.  For this project (which is basically a  
framework), we want to be able to use the components internal and  
external to the servlet container.  However, I do appreciate the  
feedback!  It helps confirm my thinking regarding potential solutions.

Cheers,
  matthew
On Wednesday, August 6, 2003, at 07:29 AM, Joseph Fifield wrote:

I don't close the session at all in any of my business logic methods.  
In
deployment, a servlet filter _always_ closes the session at the end of  
the
request. For unit testing, I have a base test case class that does the  
same
thing in the tearDown() method. That way, each test case can execute  
in the
same manner as the app running in deployment (i.e. each test case is  
like a
separate "request"). The result is each test case executes using the  
same
session, and they don't need to worry about closing it at the end.

Hope this helps...

Joe

- Original Message -
From: "Matthew E.Porter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 05, 2003 11:12 PM
Subject: [Hibernate] Unit Testing With ThreadLocal Sessions

Greetings.  I am interested in hearing how people unit test method  
that
call session.save(), update(), and delete() when the session is
provided via the ThreadLocal pattern.  For me, the primary question is
whether or not the method containing the session method calls actually
closes the database connection (session.close()) or is it called after
returning from the tested method.  From a pure unit testing
stand-point, it would seem that it would be desired to be called  
inside
the tested method.

For a project I am working on, we devised a solution (aka hack) to
solve this.  A new Session interface implementation was created that
wraps an internal Session object as normally provided.  Yet, we added  
2
methods: suspendClose() and unsuspendClose().  When closes are  
suspend,
the connection is NOT closed despite being called.  Specifically, it
does not call session.close() on the internal Session object.

When a Session is retrieved, the closes are automatically suspended.
The servlet filter unsuspends the close and closes the session if
necessary at the end of the request.
Is this a hack?  Yes.  Does it work?  Yes.  Do we get the benefits of  
a
ThreadLocal session?  Yes.  Can it be confusing to newbies who expect
close to actual close the session?  Yes, but it only has this behavior
during deployment.

Any thoughts and comments are welcome.

Cheers,
   matthew


---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/ 
direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel





---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/ 
direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Spring Framework Integration along with Open Session In View

2003-08-14 Thread Matthew E . Porter
Sandeep:
I just had this conversation with the Spring guys last week.  You may want to check their mailing list.  Here's the abridged version:  You can do it.  It is a nasty hack of the system (and beauty of Spring).  The mailing list  includes the necessary filter on how to do it.  However, it is not really recommended due to how Spring uses transactions.


Cheers,
matthew


On Wednesday, August 13, 2003, at 09:48 AM, Sandeep Dath wrote:

Hi,
 
I have a Maverick-Hibernate-DAO based project that uses the Open Session In View pattern. Now, I am trying to retro-integrate the Spring Framework into the mix.
 
Juergen's docu was excellent, but I was wondering (before I end up doing it all myself the hard way) if anybody had used Spring + Open Session In View together, and had, um, er any sharable code handy?
 
Thanks in advance
 
Sandeep


Re: [Hibernate] A Proposal: Opensymphony Conductor

2003-08-14 Thread Matthew E . Porter
Jason:
  I am all for this.  I have some new hibernate infrastructure stuff  
coming today and some patches to OSUser/PropertySets that solves the  
current performance issues.  Where do we begin and is Atlassian's  
security stuff open source?

Cheers,
  matthew
On Wednesday, August 13, 2003, at 10:40 AM, Jason Carreira wrote:

I'd like to create an opensource web application framework built on the
pieces we have and some outside libraries. Essentially I'm looking at
something like Expresso but built with better components and free :-)
I'm thinking it could consist of:

Xwork
WebWork2
OSUser
Hibernate
SiteMesh
OSCache
(Xwork IoC|Bebop|Picocontainer|Spring)
Atlassian's security stuff
All of these would be put together and configured for out-of-the-box
development with the templates, decorators, config files, etc. all set
up. It would have a build file in place and ready to go, so all you  
have
to do is start dropping your classes and HTML/JSP/VM files in and go.

If you're interested, I'd love to get feedback and I'm soliciting  
offers
of people's time and code to help set this up. Especially the JLCP  
guys,
who I know have set up some infrastructure for WW2 and Hibernate, so
that would be very helpful.

I think this would go a long way to addressing people's concerns about
ease of use (how much easier can it get without a GUI to hold your hand
and eventually strangle you :-)?)
Thanks,

Jason

--
Jason Carreira
Technical Architect, Notiva Corp.
phone:  585.240.2793
  fax:  585.272.8118
email:  [EMAIL PROTECTED]
---
Notiva - optimizing trade relationships (tm)


---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/ 
direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] Re: [OS-webwork] Re: [Opensymphony-developers] A Proposal: Opensymphony Conductor

2003-08-14 Thread Matthew E . Porter
On Wednesday, August 13, 2003, at 06:29 PM, Mike Cannon-Brookes wrote:

Joseph - where is the code? No code, no idea - sorry.

Jason - sounds like an interesting idea, but could we focus on getting 
WW2 /
XW finished and released first? :)

I disagree.  To me, this seems like the next logical progression of 
WW2/XW and the other tools.  It could serve as a way to show the power 
of WW2 and entice more developers to use it.  There are a number of 
frameworks already out there that IMHO fail to live up to expectations.



---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0013ave/direct;at.aspnet_072303_01/01
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] CGLIB2

2003-10-27 Thread Matthew E . Porter
Has Hibernate be updated to use cglib2?  If not, will it and when?

Cheers,
  matthew porter


---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] CGLIB2

2003-10-27 Thread Matthew E . Porter
Please note.  I am not asking/suggesting to change to version 2 because 
of its faster reflection code (although every little bit helps!).  I am 
asking because we want to use some of the other new features.

Cheers,
  matthew
On Oct 27, 2003, at 5:42 PM, Josh Rehman wrote:

Hmm. Cglib is neat, but reflection is so fast that I would spend my 
time elsewhere, for example adding support for a typesafe-enum 
representation of lookup tables. :-)

Gavin King wrote:
Not yet. I guess i should do it now, huh?
Matthew E. Porter wrote:
Has Hibernate be updated to use cglib2?  If not, will it and when?

Cheers,
  matthew porter


---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: 
http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel
---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel
--
Thanks,
Josh Rehman
Citysearch Toolsdev, 3559


---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] Subclassing And "net.sf.hibernate.MappingException: No persister for" Exception

2003-12-12 Thread Matthew E . Porter
Please help!!!  (I hate sending e-mails out like this, but am crunched 
for time.)

First, I am using Hibernate 2.0.3 and Spring.

I have a interface called PaymentType which has 2 implementing classes- 
CreditCardPaymentType and EmailPaymentType.  I am able to persist new 
PaymentTypes without issues; however, when associating a PaymentType to 
another object (Registration), I receive the following exception:

No persister for: 
com.demandsolutions.merovingian.payment.entity.PaymentType; nested 
exception is: net.sf.hibernate.MappingException: No persister for: 
com.demandsolutions.merovingian.payment.entity.PaymentType

Registration.java

public class Registration extends BaseEntityObject {
private PaymentType paymentType;
// other variables and methods..

// Hibernate Mappings declared in supplementary file!
public PaymentType getPaymentType() {
return this.paymentType;
}
public void setPaymentType(PaymentType paymentType) {
this.paymentType = paymentType;
}
}

Registration.hbm.xml



// other declarations
  


  




Any and all help is appreciated!  Thanks in advance!



Cheers,
  matthew






---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Subclassing And "net.sf.hibernate.MappingException: No persister for" Exception

2003-12-12 Thread Matthew E. Porter
Any guess on where I can start looking for the problem?

One other thing I did not detail is that CreditCardPaymentType is an abstract
class with a few implementations.

This is holding up a site from being deployed and driving me absolutely crazy! 
Thanks in advance!


Cheers,
  matthew



Quoting Gavin King <[EMAIL PROTECTED]>:

> Not true, you can map interfaces as a superclass. But in this case 
> Matthew is anyway using any  association by the looks of it, so he 
> doesn't need to. Can't see the problem though.
> 
> Bear Giles wrote:
> > Matthew E.Porter wrote:
> > 
> >> I have a interface called PaymentType which has 2 implementing 
> >> classes- CreditCardPaymentType and EmailPaymentType.
> >>
> >> No persister for: 
> >> com.demandsolutions.merovingian.payment.entity.PaymentType; nested 
> >> exception is: net.sf.hibernate.MappingException: No persister for: 
> > 
> >  > com.demandsolutions.merovingian.payment.entity.PaymentType
> > 
> > I'm not 100% certain of this answer, but I believe the problem is that 
> > PaymentType is an interface instead of a class.  Hibernate can only 
> > persist a class.  (Even if it's an abstract class?)
> > 
> > I'm not sure why you didn't have problems persisting PaymentType directly.
> > 
> > 
> > 
> > ---
> > This SF.net email is sponsored by: IBM Linux Tutorials.
> > Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
> > Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
> > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> > ___
> > hibernate-devel mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> 
> -- 
> Gavin King
> JBoss Group
> +61 410534454
> http://hibernate.org
> 
> 
> 
> ---
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
> Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> ___
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> 




This message was sent using IMP, the Internet Messaging Program.


---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel