Re: [Hibernate] HB3 docs

2005-02-09 Thread Emmanuel Bernard
Done.
I've started a paragraph on metrics analysis (eg wrong cache hit ratio 
etc). Feel free to contribute from experience.

Emmanuel Bernard wrote:

Gavin King wrote:
Ive spent the last three days rewriting much of the user manual. 
Its much improved.

There are still two small tasks left:
   * finish rewriting transaction chapter (Christian is doing this)
   * document Statistics and JMX monitoring (Emmanuel, can you spare
 some time to do this?)

I'll do it
The user manual is now 170 pages, all fact-checked, all basically 
understandable, I think. Together with HiA, I dont think anyone can 
fairly complain about documentation anymore

Thanks,
Gavin

--
Emmanuel Bernard
[EMAIL PROTECTED]
callto://emmanuelbernard
http://www.hibernate.org


---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] My first Hibernate App,.. got some question, appreciate ur help

2005-02-09 Thread pkaka2

Hi everybody,

well, i thought let me try working on some example using Hibernate ORM...

I somehow made it work..
part of the code:

conn=ds.getConnection(uname,passwd);

Configuration cfg=new Configuration();
cfg.addClass(testing.Department.class);
cfg.setProperties(System.getProperties());
SessionFactory sf=cfg.buildSessionFactory();

// try without passing connection

//Session sess1=sf.openSession(); 

Session sess1=sf.openSession(conn); 
//Transaction trans=sess1.beginTransaction();

Department dept=new Department();
dept.setName(abc);dept.setCity(xyz);dept.setState(xx);
sess1.save(dept);

sess1.flush(); 
// as well as commit yourself unless using transactionsupport 
 sess1.connection().commit(); 


//trans.commit();
sess1.close();  


I get it working, only when i pass the connection like:
Session sess1=sf.openSession(conn);

if not i always get an error, saying
java.lang.UnsupportedOperationException: The user must supply a JDBC connection

So, i guess, something wrong with my hibernate.properties, i have got no clue 
where it is wrong..

this is where i am supplying the required information in hibernate.properties:



 ## JNDI Datasource 
 
 hibernate.connection.datasource jdbc/jndiname
 hibernate.connection.username user
 hibernate.connection.password passwd 
 
 ## DB2/400  
 
 hibernate.dialect net.sf.hibernate.dialect.DB2400Dialect
 
 hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
 
 hibernate.connection.url jdbc:as400://systemName
 hibernate.connection.username userhibernate.connection.password passwd 


I know, people who are very comfortable with Hibernate, will definitely know 
what is going wrong..

I thank you very much for your help.. I appreciate.. :-)

I am using Websphere app server on AS400,.. DB2 included in AS400..
and since the tables are not Journaled, i commented the Transaction, which are 
not supported incase tables are not journaled,.. that is the problem with DB2 
on AS400..when i think of using Hibernate.. 










---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] My first Hibernate App,.. got some question, appreciate ur help

2005-02-09 Thread Christian Bauer
On Feb 10, 2005, at 1:27 AM, [EMAIL PROTECTED] wrote:
well, i thought let me try working on some example using Hibernate 
ORM...
There is a user forum, this is the developer list.
--
Christian Bauer
callto://christian-bauer
Hibernate
[EMAIL PROTECTED]
http://hibernate.org
JBoss Inc
[EMAIL PROTECTED]
http://jboss.com

---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Is it worth contributing this code or posting it somewhere?

2005-02-09 Thread Adrian Ridner
(Sorry if this is a duplicate email, but I did not see it in the list, and it's been a few days...)

Gavin,

Thanks for the reply. When we looked at the docs and HiA (and experimented) we didn't see a way to load multiple collections for an object and any properties and collections of those collections, n levels deep. We could have totally missed it, but as an example:

Criteria crit = sess.createCriteria(Advertisement.class);
returnList = crit.setFetchMode(Advertisement.PROP_BID, FetchMode.EAGER)

.setFetchMode(Advertisement.COL_ADVERTISEMENTKEYPHRASES_BY_ADVERTISEMENT_ID, FetchMode.EAGER)
.setFetchMode(Advertisement.COL_CREATIVES_BY_ADVERTISEMENT_ID, FetchMode.EAGER)
.list()


As far as we can tell, this loads the Advertisement(s), its Bid property (and we could load any other top level properties of Advertisement we'd want -- and it would load them using left join fetch) and the creatives collection but it does *not* load the advertisementkeyphrases collection. To accomplish this we had to add:  

Hibernate.initialize(ad.getAdvertisementkeyphrasesByAdvertisementId()) which ran into the n+1 issue.

We did not find a way to load a collection or property of creatives and filter them (at least none of the examples / our code seem to do it and returnMaps show as deprecated?). Other minor things our code does is to filter items in the collections we are loading by any where statement (filters in H3?) and it deals with the distinct issue. But the major thing was still the ability to load an entire tree completely, not just the branch of one collection, n levels deep, avoiding the n + 1 problem.

Did we miss something? I'll be optimistic and hope we didn't reinvent the wheel, but if we did, it was a fun exercise :)

Adrian


On Feb 6, 2005, at 10:46 PM, Gavin King wrote:

x-tad-biggerHow is this different to the Criteria query API?/x-tad-bigger

x-tad-bigger /x-tad-bigger


x-tad-biggerFrom:/x-tad-biggerx-tad-bigger [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] /x-tad-biggerx-tad-biggerOn Behalf Of /x-tad-biggerx-tad-biggerAdrian Ridner/x-tad-bigger
x-tad-biggerSent:/x-tad-biggerx-tad-bigger Monday, 7 February 2005 5:41 PM/x-tad-bigger
x-tad-biggerTo:/x-tad-biggerx-tad-bigger 'hibernate-devel@lists.sourceforge.net'/x-tad-bigger
x-tad-biggerCc:/x-tad-biggerx-tad-bigger [EMAIL PROTECTED]/x-tad-bigger
x-tad-biggerSubject:/x-tad-biggerx-tad-bigger [Hibernate] Is it worth contributing this code or posting it somewhere?/x-tad-bigger

 

I would like your opinion if this code is the type of thing you would ever add to Hibernate or if we should take the time to post it in our website for download. I saw some postings in the User Forum asking for similar things, but you guys would know better. It is currently working with Hibernate 2.1.8. The code deals with having everything in the mapping files be lazy=true and allowing the user to load an object and specify the object graph to load for that object in the code. Instead of using Hibernate.initialize() (n+1 queries approach), it optimizes said queries by using left join fetch on all the properties and all collections, being smart enough to issue only one query per collection. Note the number of properties loaded does not affect the number of queries issued.

  

The code below is a sample from one of our DAOs, which extends from our BaseHibernateDAO (it has convenience methods and object graph loading methods). I indented it one more level every time an object is added for a deeper node in the graph (I doubt all mail clients will maintain the indentation, and it helps quite a bit, so I posted it here also http://remilon.com/maintainindentation.html ). WIthout getting into a lot schema specifics, it loads an 'Advertisement' bean and a variety of its collections and their objects. This is a particularly deep object graph, as an illustration.

 x-tad-bigger /x-tad-bigger

x-tad-biggerpublic Advertisement getAdvertisementTree(int advertisementId) {/x-tad-bigger

x-tad-bigger LazyInitializer init = new LazyInitializer();/x-tad-bigger

x-tad-bigger init/x-tad-bigger

x-tad-bigger .addCollection(Advertisement.COL_ADVERTISEMENTKEYPHRASES_BY_ADVERTISEMENT_ID, advkp)/x-tad-bigger

x-tad-bigger .addNamedProperty(advkp, Advertisementkeyphrase.PROP_KEYPHRASE, kp)/x-tad-bigger

x-tad-bigger .addNamedProperty(kp, Keyphrase.PROP_PHRASE)/x-tad-bigger

x-tad-bigger .addNamedCollection(advkp, Advertisementkeyphrase.COL_ARTIFACTS, art1)/x-tad-bigger

x-tad-bigger .addNamedCollection(art1, Artifact.COL_BIDS)/x-tad-bigger

x-tad-bigger .addNamedCollection(art1, Artifact.COL_DESTINATION_PAGES, destpg1)/x-tad-bigger

x-tad-bigger .addNamedProperty(destpg1, DestinationPage.PROP_SITE)/x-tad-bigger

x-tad-bigger .addNamedCollection(art1, Artifact.COL_ROUTINGS, routings1)/x-tad-bigger

x-tad-bigger .addNamedProperty(routings1, Routing.PROP_SITE)/x-tad-bigger

x-tad-bigger .addCollection(Advertisement.COL_CREATIVES_BY_ADVERTISEMENT_ID, ct)/x-tad-bigger

x-tad-bigger .addNamedProperty(ct, 

Re: [Hibernate] Is it worth contributing this code or posting it somewhere?

2005-02-09 Thread Adrian Ridner
On Feb 7, 2005, at 9:17 PM, Christian Bauer wrote:
On Feb 7, 2005, at 11:08 PM, Adrian Ridner wrote:
Did we miss something? I'll be optimistic and hope we didn't reinvent 
the wheel, but if we did, it was a fun exercise :)
Read up on the docs some more. What you try to do would create a 
Cartesian product and be slower than two queries (which is what you 
discovered will happen). This is documented in every other place and a 
sensible limitation. You can write a custom SQL query in very special 
cases, if you are sure the product is faster than two queries.

Thanks for the reply. Sorry I didn't see it before, it got lost in my 
mailbox. I appreciate your feedback.  I guess that answers my original 
question.  We'll read up the docs more to see if we find anything. I am 
wondering if I didn't communicate what we are doing correctly though, 
because we are running this on tables with 5,000,000 rows each, and it 
is faster than anything else we tried.

In any case, thank you for a great product!
Adrian

---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Is it worth contributing this code or posting it somewhere?

2005-02-09 Thread Christian Bauer
On Feb 10, 2005, at 5:16 AM, Adrian Ridner wrote:
Thanks for the reply. Sorry I didn't see it before, it got lost in my 
mailbox. I appreciate your feedback.  I guess that answers my original 
question.  We'll read up the docs more to see if we find anything. I 
am wondering if I didn't communicate what we are doing correctly 
though, because we are running this on tables with 5,000,000 rows 
each, and it is faster than anything else we tried.
Then I'm sure it doesn't work. A product with 5.000.000 x 5.000.000 
rows would be noticeable.

--
Christian Bauer
callto://christian-bauer
Hibernate
[EMAIL PROTECTED]
http://hibernate.org
JBoss Inc
[EMAIL PROTECTED]
http://jboss.com

---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


RE: [Hibernate] Is it worth contributing this code or posting it somewhere?

2005-02-09 Thread Jordan Laughlin








Hello, I just wanted to jump in
because I'm really not clear on how the queries produced could result in a
cartesian product. Since every level of the graph contains an on
clause that references the table before it, each level of the tree is limited
(by
its
particular join type) and the amount of results
returned at each level will be the amount of rows in the
largest subset that meets its join condition.

For instance,

[SQL QUERY]

Select * from A join B on A.id = B.id join C on C.id = B.id join
D on D.id = C.id left join E on E.id = D.id

This is exactly what our queries do: this does not result in a
cartesian product, it returns at a maximum the number of rows in the largest
table that meets a join condition. Now in each of our queries we may join any
number of properties by left join since we know
each join will return only one row (criteria does this as well). The cartesian product would show its ugly head if we instead
attempted to load multiple collections per query, which is
not what we are doing: instead we
are doing one query per collection. 

For instance, if we wish to load A, its B property,
and the collections C and D of property B, we would issue two
different queries:

[HIBERNATE QUERIES]

Select A from A left
join
fetch
B
on A.id = B.id left join
fetch
C
on C.id = B.id;

And

Select B from A left
join
fetch
B
on A.id = B.id left join
fetch
D
on D.id = B.id;

Since B is a property, it's left join
returns only one row. By issuing the above queries in order in the same
session, we get A, it's B property loaded, and the collections C and D for
the
B in A fully loaded.

As far as
we know Hibernate currently does not allow for object graph loading (loading a
collection of a collection, etc.). The purpose of our code was to do that: if
you can suggest a better way of doing this, or a way to split up the above
queries when loading the graph, which avoids n+1 selects, please point us to
the documentation.

Thanks,

Jordan

-Original Message-
From: Adrian Ridner
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday,
 February 09, 2005 8:16 PM
To: 'hibernate-devel@lists.sourceforge.net'
Cc: [EMAIL PROTECTED]
Subject: Re: [Hibernate] Is it worth contributing this
code or posting it somewhere?



On Feb
 7, 2005, at 9:17 PM,
Christian Bauer wrote:



 On Feb
 7, 2005, at 11:08 PM,
Adrian Ridner
wrote:



 Did we miss something? I'll be optimistic and hope we
didn't reinvent 

 the wheel, but if we did, it
was a fun exercise :)



 Read up on the docs some more. What you try to do would
create a 

 Cartesian product and be slower than two queries (which is
what you 

 discovered will happen). This is documented in every other
place and a 

 sensible limitation. You can write
a custom SQL query in very special 

 cases, if you are sure the product
is faster than two queries.



Thanks for the reply. Sorry I didn't see it before, it got lost
in my 

mailbox. I
appreciate your feedback. I guess that answers my original 

question.
We'll read up the docs more to see if we find anything. I am 

wondering if
I didn't communicate what we are doing correctly though, 

because we
are running this on tables with 5,000,000 rows each, and it 

is
faster than anything else we tried.

In any case, thank you for a great product!

Adrian