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WVzIG9mIEhpYmVybmF0ZSAyLjAuMyB3aXRoIFNwcmluZy4gVGhhdCdzIDEu NiBhZGRpdGlvbmFsIE1Ccywgd2l0aG91dCB0aGUgSkNTIGNhY2hlLiBEb2VzIGFueW9uZSBvYmpl Y3QgdG8gdGhhdD8NCiANClAuUC5QLlMuOg0KV2h5IGlzICJNeVNRTE1heFZhbHVlSW5jcmVtZW50 ZXIiIHdyaXR0ZW4gd2l0aCB1cHBlci1jYXNlICJTUUwiIGJ1dCAiSHNxbE1heFZhbHVlSW5jcmVt ZW50ZXIiIG5vdD8gSXMgaXQganVzdCBiZWNhdXNlIENWUyBkb2Vzbid0IHN1cHBvcnQgY2FzZSBy ZW5hbWluZz8gOy0pDQogDQo= |
|
From: Trevor C. <pr...@se...> - 2003-10-20 02:31:33
|
Cool. I might actually be able to learn more about Hibernate now (lots =
of desire, absolutely no time :) ).
>>auto-increment just allows to read in the actual id afterwards
This is not reliable for concurrent inserts (which is why I generally =
use sequences. For the sample this should be sufficient though.
Trevor
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf
Of j=C3=BCrgen h=C3=B6ller [werk3AT]
Sent: October 19, 2003 6:48 PM
To: spr...@li...
Subject: [Springframework-developer] Petclinic Hibernate implementation
Hi everybody,
=20
I've just finished something that I wanted to get in M2: a Hibernate =
implementation of Petclinic! The main rationale is to provide a working =
Spring/Hibernate sample app -- adapting Petclinic was the easiest way. =
And it's nice to switch between the JDBC implementation and the =
Hibernate one... The new impl is basically just an alternative =
implementation of the Clinic business interface, but I've generally =
refined that interface and the domain objects in the course of the work. =
I've also renamed the root package from "petclinic" to =
"org.springframework.samples.petclinic", analogous to the countries =
demo.
=20
Generally, everything works nicely so far on both implementations. =
There's one issue though: HsqlJdbcClinic uses HsqlMaxValueIncrementer =
for id generation, with one sequence table per domain table. Hibernate =
doesn't have a similar id generation strategy, so I'm wondering what to =
do to make both impls work on the same database. The Hibernate docs say =
that HSQL supports "identity" for id columns; why are we not using this =
for HsqlJdbcClinic too? I.e. making the id columns identity columns and =
getting rid of all the sequence tables. I guess there's a drawback with =
this; can anyone shed some light on the issue?
=20
BTW, we are using auto-increment for all MySQL databases at werk3AT, and =
it works nicely. I'd really like to understand the rationale for manual =
sequence handling. The only one I see is that the id can be determined =
before the domain insert/update statement this way, while auto-increment =
just allows to read in the actual id afterwards. But does that really =
matter for Petclinic? Wouldn't it be easier to use =
auto-increment/identity on both MySQL and HSQL?
=20
This issue is pretty urgent actually, as I'd like to get M2 out mid next =
week; that's already slightly behind the original schedule with a =
release this weekend. I believe that a working Spring/Hibernate sample =
(the number one question on the Hibernate forums) is worth a slight =
delay, though.
=20
Juergen
=20
P.S.:
Jean-Pierre, what's the status of your Light-Countries sample? Do we =
really need it? Countries configured to the memory DAO should be nice =
enough... I do not intend to include it in distributions, for the time =
being.
=20
P.P.S.: To make the Hibernate impl of Petclinic work out-of-the-box, we =
need to ship the main libraries of Hibernate 2.0.3 with Spring. That's =
1.6 additional MBs, without the JCS cache. Does anyone object to that?
=20
P.P.P.S.:
Why is "MySQLMaxValueIncrementer" written with upper-case "SQL" but =
"HsqlMaxValueIncrementer" not? Is it just because CVS doesn't support =
case renaming? ;-)
=20
+=12=17 ?[){([ ' +=1E.) Z+??`zw=1E Li8^=12Z+.) =
6??ig [ +kj?"8^=12{^? b^=06?v(=17?9 q {ay' ? 0 +=1E) +o o =
*kx=1F ?zZ)zXX*kx=1F? ?zZ)z l .a=1Ew i +-(=1E~ { b ?+-w k?x=1F? =
?zZ)
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.525 / Virus Database: 322 - Release Date: 09/10/2003
|
|
From: Colin S. <col...@ex...> - 2003-10-20 03:45:30
|
jürgen höller [werk3AT] wrote:
>Hi everybody,
>
>...
>
>BTW, we are using auto-increment for all MySQL databases at werk3AT, and it works nicely. I'd really like to understand the rationale for manual sequence handling. The only one I see is that the id can be determined before the domain insert/update statement this way, while auto-increment just allows to read in the actual id afterwards. But does that really matter for Petclinic? Wouldn't it be easier to use auto-increment/identity on both MySQL and HSQL?
>
>
>
Only somewhat related, but how does the auto-increment get handled
w/regards to Hibernate's 'save' function? That is, with an Oracle
sequence or some of the other (hi/lo, etc.) strategies, when you call
Hibernate's save function, your objects will get proper ids, even though
they don't get written to the db until they actually get flushed. This
is because the db has already been hit for the Oracle sequence or for
the manual sequence table column.
What happens in your case with MySQL's auto-increment columns
(essentially similar to SQL Server's identity columns). Do the IDs stay
null (or whatever the unsaved value is) until Hibernate's flush actually
gets called?
Just curious since I've never used either MySQL or SQL Server with
Hibernate...
Colin
tell Hibernate to
How do you properly handle
>This issue is pretty urgent actually, as I'd like to get M2 out mid next week; that's already slightly behind the original schedule with a release this weekend. I believe that a working Spring/Hibernate sample (the number one question on the Hibernate forums) is worth a slight delay, though.
>
>Juergen
>
>P.S.:
>Jean-Pierre, what's the status of your Light-Countries sample? Do we really need it? Countries configured to the memory DAO should be nice enough... I do not intend to include it in distributions, for the time being.
>
>P.P.S.: To make the Hibernate impl of Petclinic work out-of-the-box, we need to ship the main libraries of Hibernate 2.0.3 with Spring. That's 1.6 additional MBs, without the JCS cache. Does anyone object to that?
>
>P.P.P.S.:
>Why is "MySQLMaxValueIncrementer" written with upper-case "SQL" but "HsqlMaxValueIncrementer" not? Is it just because CVS doesn't support case renaming? ;-)
>
>N?HY隊[)?{(??[?I?z?k?Nj?{???*'}?ޝDŽƚ??/z{E????Cj֜z{^?*%?ب?ĭ??^?'??t?xI?z?k?Nj?{??{ax???h??????9??q觶?z?ޭ(?m????????+?)???+?g(?*k?x????u?ޖ?^?f??)?+-J???jg???z???+-??.?ǟ????a??l??b??,???y?+???b????+-?w???k?x????u?ޖ?^r===
>
|
|
From: <tri...@tr...> - 2003-10-20 13:48:38
|
Juergen, > Generally, everything works nicely so far on both implementations. There's > one issue though: HsqlJdbcClinic uses HsqlMaxValueIncrementer for id > generation, with one sequence table per domain table. Hibernate doesn't have > a similar id generation strategy, so I'm wondering what to do to make both > impls work on the same database. The Hibernate docs say that HSQL supports > "identity" for id columns; why are we not using this for HsqlJdbcClinic too? > I.e. making the id columns identity columns and getting rid of all the > sequence tables. I guess there's a drawback with this; can anyone shed some > light on the issue? > Does Hibernate use a different ID strategy for different databases? I think what is implemented in the Petclinic is a strategy that would work the same across different databses as long as there is a MaxValueIncrementer implementation. If we change the Petclinic JDBC implementation to use identity columns, then we need to figure out how to run the insert and subsequent query to retrieve the id using the same connection whether we are in a transaction or not. Thomas |
|
From: Colin S. <col...@ex...> - 2003-10-20 15:03:32
|
tri...@tr... wrote: >Juergen, > > > > >>Generally, everything works nicely so far on both implementations. There's >>one issue though: HsqlJdbcClinic uses HsqlMaxValueIncrementer for id >>generation, with one sequence table per domain table. Hibernate doesn't have >>a similar id generation strategy, so I'm wondering what to do to make both >>impls work on the same database. The Hibernate docs say that HSQL supports >>"identity" for id columns; why are we not using this for HsqlJdbcClinic too? >>I.e. making the id columns identity columns and getting rid of all the >>sequence tables. I guess there's a drawback with this; can anyone shed some >>light on the issue? >> >> >> > >Does Hibernate use a different ID strategy for different databases? I think >what is implemented in the Petclinic is a strategy that would work the same >across different databses as long as there is a MaxValueIncrementer implementation. > >If we change the Petclinic JDBC implementation to use identity columns, then we >need to figure out how to run the insert and subsequent query to retrieve the id >using the same connection whether we are in a transaction or not. > >Thomas > > > Hibernate has an id strategy called 'native', where it then actually uses identity, sequence, or hilo strategies for generating the id, depending on the db you are talking to. This works pretty well as long as you don't care about the exact format of your ids. |