Re: [Hibernate] questions about polymorphism

2003-08-07 Thread Gavin . King

>> It seems that if I use "table-per-class", I am going to get hit
with thirty queries every time I do a select of the superclass, is that
correct?  <<

Correct

>> But if I use "table-per-subclass" with , I will
get two selects -- one for the superclass result set and one for each table
(or table type) that exists in the result set. <<

No, Hibernate uses a great big outer join, because there is no
discriminator column in joined-subclass mappings.


The subclass fetching strategy you just described (we need to give it a
name) is subject to the N+1 selects problem. However, I *do* plan to
support it in a not too distant future version. (Hibernate 2.1.1 perhaps.)
Actually,  It will be a variation of the proposed multi-table mapping
support, ie. the  mapping. For multitable mappings we will support
both  and . So the fetching strategy you describe
would be implementable as B and C in the following:



















   







  




So we now have a fully mixed inheritance strategy!! This hierarchy combines
together a table-per-subclass loaded by joining, 2 table-per-subclasses
loaded by sequential read and another subclass mapped to the superclass
table.

Don't expect this stuff in the next two weeks, however!

>> Since the subclass is
completely described this way, is the separate mapping file for the
subclass
redundant?  <<

You should not have a seperate mapping file for a subclass.







|-+--->
| |   "Brian Topping" |
| |   <[EMAIL PROTECTED]> |
| |   Sent by:|
| |   [EMAIL PROTECTED]|
| |   ceforge.net |
| |   |
| |   |
| |   07/08/03 04:19 PM   |
| |   |
|-+--->
  
>--|
  |
  |
  |   To:   <[EMAIL PROTECTED]>
  |
  |   cc:  
  |
  |   Subject:  [Hibernate] questions about polymorphism   
  |
  
>--|




Hi all,

I have some questions about polymorphic persistence.  Any takers?

I have a schema that currently has about thirty subclasses (more with time)
and one common superclass.  I am looking for polymorphism between these
subclasses.  It seems that if I use "table-per-class", I am going to get
hit
with thirty queries every time I do a select of the superclass, is that
correct?  But if I use "table-per-subclass" with , I will
get two selects -- one for the superclass result set and one for each table
(or table type) that exists in the result set.  Since most of the
collections
are of a single subtype, this seems to be the most efficient.  True?

[a comment: adding a "WildCat" subclass to the documentation example next
to
"DomesticCat" would be helpful, although it may add unnecessary complexity
to
the single page manual, since there are no examples of having multiple
subclasses with a common parent.]

Finally, if I understand the mapping file schema correctly, the superclass
mapping file is going to be very very large, essentially containing all of
the subclasses in  entities.  Since the subclass is
completely described this way, is the separate mapping file for the
subclass
redundant?

Thanks for any thoughts!!

Brian


---
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




**
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as 

Re: [Hibernate] useLimit problems.

2003-08-07 Thread Fredrik Larsson
Hmm posted too soon as always :-(

After studying the code some more I noticed that hibernate will use the 
setMaxRows() method on the PreparedStatement instead of adding a limit 
expression to the sql statement.
Hopefully this is just as good. I'll have to make sure it is.

Sorry for the inconvenience
Fredrik
From: "Fredrik Larsson" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [Hibernate] useLimit problems.
Date: Tue, 05 Aug 2003 16:09:49 +0200
Hello.

I'm having some troubles with useLimit() in net.sf.hibernate.loader.Loader  
(hibernate 2.0)

The method looks like this

private boolean useLimit(RowSelection selection, SessionImplementor 
session) {
 Dialect d = session.getFactory().getDialect();
 return d.supportsLimit() &&
  ( selection!=null && selection.getMaxRows()!=null ) && //there 
is a max rows
  ( d.preferLimit() || getFirstRow(selection)!=0 );
}


My problem is that I want use setFirstResult(0), setMaxResults(100) when I 
retrieve the first part of a LAAARGE result set. Because of the 
getFirstRow(selection)!=0 expression in the implementation above a limit 
clause will not be added to the SQL statement.

My workaround is setFirstResult(1) but then I will not be able to retrieve 
one row (the first one) from the database.

Question:
Am I missing something obvious here or is this a bug?
Kind Regards
Fredrik Larsson
_
Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/


---
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
_
Hitta rätt på nätet med MSN Sök http://search.msn.se/


---
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] Help Wanted :)

2003-08-07 Thread Gavin . King
David Channon has implemented support for Dialect-specific SQL functions in
the HQL select clause. This means that we need to go though the dialects,
one by one, and fill in the standard functions for that Dialect. David has
already done this for Oracle. It would be very nice if some platform
experts could help by submitting patches for the others. Thanks!


**
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as applicable.

This email, including all attachments, is confidential.  If you are not the
intended recipient, you must not disclose, distribute, copy or use the
information contained in this email or attachments.  Any confidentiality or
privilege is not waived or lost because this email has been sent to you in
error.  If you have received it in error, please let us know by reply
email, delete it from your system and destroy any copies.
**






---
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] Help : Bidirectionally Polymorphic One to Many associations

2003-08-07 Thread Dhananjay Nene
I have the following scenario and have been unable to resolve the underlying 
issues by reading either the manual or the faq.



I have two inheritance hierarchies. eg. Customer is a base class and 
InternalCustomer and ExternalCustomer are derived classes. Similarly
Location is a base class whereas IndustrialLocation and CommercialLocation
are derived classes.

We have chosen to implement the table-per-concreteclass strategy (ie. each 
table has columns for the base class as well). So in a scenario where say an 
Invoice needs a reference to a customer, I have set up an "" relationship 
from invoice to customer, by using customerType and customerId columns in the 
invoice table. 

However we need to setup a "one-to-many" relationship between a customer and a 
location (ie. polymorphic both ways with tables created for leaf classes only).
This can be easily done at a table level by creating "customerType" 
and "customerId" columns in each of the location tables. I have also been able 
to be able to reference the customer object from a location object by using 
the "" tag in the hbms of the location classes. I am unable to decide how 
to implement the relationship from customer to location using hibernate. 

I am looking for the ability to implement the "Set getLocations()" method in 
Customer.

The following option does come to my mind (not certain if it is necessarily 
implementable)

a. Implement getIndustrialLocations() and getCommercialLocations() seperately. 
This requires my customer class to not be able to deal with Locations 
polymorphically. Moreover it will require me to modify the source as and when I 
add new Derived classes for Location.   

I am however struggling for a better solution. Any suggestions will be welcome.

Thanks
Dhananjay


---
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] outer-join attribute for collection mappings

2003-08-07 Thread Gavin . King
Well, I still think that this is almost always a Bad Thing, but it is now
possible to configure (exactly one) collection to be loaded by outer join
in the mapping file.

This will affect the fetching beviour for

* load()
* Criteria queries
* lazy association access

It does not affect the behaviour of HQL queries, which provide the FETCH
clause.

Implementing this feature did allow me to make some nice design
improvements to OuterJoinLoader.

Theres still some extra thought to go on the code which decides exactly
when to do the outer join and when not to. This feature could result in
some extremely deep fetching, so I'm thinking of adding a
hibernate.max_outerjoin_fetch_depth property or something.

All in v21branch.


**
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as applicable.

This email, including all attachments, is confidential.  If you are not the
intended recipient, you must not disclose, distribute, copy or use the
information contained in this email or attachments.  Any confidentiality or
privilege is not waived or lost because this email has been sent to you in
error.  If you have received it in error, please let us know by reply
email, delete it from your system and destroy any copies.
**






---
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] Moving Hibernate objects with SOAP

2003-08-07 Thread Brian Topping
Title: RE: [Hibernate] Moving Hibernate objects with SOAP



Hi 
Jon,
 
One of 
the things that I currently do is use XDoclet to generate inline transforms for 
going back and forth from XML to entity.  You end up with hardcoded 
serializers, which are very fast, but I don't have enough experience with it yet 
to know what extended maintenance is going to be like.  It would 
theoretically be possible to generate a schema/dtd that goes with the 
serializers, and one maintenance process might rename the then-current 
serializers and schema pair to something new as the system grew (giving the 
ability to support backwards compatibility).  Some environments won't need 
all this though. 
 
Note 
that I am currently using it with XDoclet value objects (DTOs, if I understand 
the two correctly) from entity beans.  So what I have will need a bit of 
work to make it work with Hibernate POJOs, but not much and I plan on doing that 
work within the next few days.  As it works today, simply changing 
your XDoclet tags for your entities rewrites the serializers 
automagically.  The same thing will happen with the POJOs when I am 
done.
 
I can 
forward or post what I have when I have it for anyone that is interested.  
I've thought about integrating this into the mainline XDoclet tree, but wanted 
to get some experience with it first.  If anyone has thoughts about such an 
integration (pro/con), please share.
 
best,
 
-b

  -Original Message-From: Jon Lipsky 
  [mailto:[EMAIL PROTECTED]Sent: Thursday, August 07, 2003 4:59 
  PMTo: 'Josh Rehman'; 
  '[EMAIL PROTECTED]'Subject: RE: [Hibernate] 
  Moving Hibernate objects with SOAP
  Hi Josh, 
  I needed to send my objects over SOAP as well (though using 
  GLUE, not Axis).  What I ended up doing was write a custom 
  serializer/deserializer that would write my hibernate data objects to and from 
  XML.  When I want to send the object over the wire, it is serialzed to 
  XML, and then on the client side it deserialzed back into it's object 
  state.  Doing it this way means that I have fine control over how much of 
  the data hibernate lazily loads, meaning it only loads what I want it to send 
  over the wire.
  The methods that are exposed with SOAP just send byte arrays 
  around, and there is an API that wraps those methods that to handle the 
  deserialization/serialization.  Doing it this way allowed me to avoid 
  having to add special "DTO" objects into my model.
  Regards, Jon... 
  -Original Message- From: Josh 
  Rehman [mailto:[EMAIL PROTECTED]] 
  Sent: Thursday, August 07, 2003 2:46 AM 
  To: [EMAIL PROTECTED] Subject: [Hibernate] Moving Hibernate objects with SOAP 
  Hello all, 
  I'd like to move Hibernate generated objects (generated with 
  hbm2java, of course) across the wire with SOAP. 
  
  There are two problems: 
  First, Hibernate generates collection accessors. This is 
  great, but these are, by necessity, untyped. The Axis 
  serializer cannot handle this. 
  Second, it often comes to pass that we are only interested in 
  a subset of the object. In particular, we often do NOT 
  want to move an entire collection accross the wire. 
  Unfortunately, the serializer will call all accesors 
  on the hibernate object, and CGLIB will, of course, do it's job 
  and get everything known about that object. 

  We have so far tried to solve these problems by writing an 
  additional code generator that creates so-called "Data 
  Transfer Objects" (Fowler's term, also abreviated DTO) 
  that have a) typed array accessors, and b) the ability 
  to specify a subset of interesting properties. We aren't quite done with this effort, but it's so far working out well. The DTOs 
  are generated by delegating work to an underlying 
  hibernate class. 
  Has anyone faced and solved, these probelms? If so, I'd like 
  to hear about it. In particular, I was hoping that 
  there is something obvious that I may have 
  missed. 
  With kind regards, Josh Rehman 
  
  --- 
  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] hbm2java patch for generating find methods

2003-08-07 Thread Max Rydahl Andersen
This is already fixed in CVS - old news ;)

Sorry that i did not bite on your posting earlier, but with approx. 150 
mails per day regarding hibernate one or two will slip ;(

/max

[EMAIL PROTECTED] wrote:

The following is in the patch. This patch is based on a question I posted
earlier today
(http://sourceforge.net/forum/forum.php?thread_id=912698&forum_id=128638),
but got no bites on. 

I did have to change the build to work with hibernate-2.0.2 as the build.xml
was looking for ../../hibernate-2.0/lib. 

I fixed two problems here.

1)Only findAll was getting generated, no matter how many finder-method's
were defined at the property level. To fix this, I simply changed the value
of MT_FINDERMETHOD from "finder" to "finder-method".
2)The wrong SQL or HQL was getting generated for the findAll() method.
Basically, it had "from className in class package.className" and hibernate
was complaining by something like: "unexpected token: in [from Organization
in class net.sf.jameleon.jdo.Organization]". I took out the text "in class
package.ClassName" for the findAll method generation code.
I hope this helps.





---
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-07 Thread Joseph Fifield
They are not coupled with the web tier. They only require _something else_
to close the session at the appropriate time. In a web application, it
happens to be a servlet filter. In test cases, it happens to be the
tearDown() method. There is no dependency on the web tier when running the
test cases. If you have other scenarios, you just need to find an
appropriate place to close the session (maybe a controller of some sort).

Joe

- Original Message - 
From: "Matthew E.Porter" <[EMAIL PROTECTED]>
To: "Joseph Fifield" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, August 06, 2003 9:59 AM
Subject: Re: [Hibernate] Unit Testing With ThreadLocal Sessions


> 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] Problem with SchemaUpdate

2003-08-07 Thread Oliver Wehrens
Hi,

ich have a class and a mapping. Now I enhance the class and mapping
and I want to run SchemaUpdate from inside my code.
I add a property 'old' to my code as well as to the mapping file.
The generated sql update statement is:
alter table xattr add columnold VARCHAR(20)
alter table attributes add index (xxx), add constraint FK182DA9571D178 
foreign key (xxx) references xattr (oid)

I believe it should be 'alter table xattr add column old VARCHAR(20)' so
a space between 'column' and 'old'. It added now a column called
columnold and not old.
I'm using 2.0.1 and mysql.

Oliver



---
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