This is the expected behaviour in Hibernate 1.x. However, Hibernate2 is
less fussy and
doesn't mind if you delete an object twice.
Matt
Oh. I think I realized what your problem is. heh.
You need to do:
new Configuration.configure().buildSessionFactory();
slightly different to the old form.
---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM +
Yup, that looks nice; submit a patch.
The JMX property for transaction.factory_class is called
transactionStrategy (just for confusion's sake)
Shouldn't need to. You should only need to provide
a name attribute to the session-factory element.
Note that this stuff was broken in beta 1, but I think
it is working in beta 2.
I deprecated it because I don't want SchemaExport to depend upon
functionality that is available on so few platforms. However, SchemaUpdate
probably *could* be allowed to use this. So I havn't removed it yet.
That pattern should work fine, as long as the id generator only generates
32-bit values.
Alternatives:
* use a custom IdentifierGenerator
* use Hibernate2 which is a bit smarter in how it handles types
If you don't want the save() to cascade, you should set cascade=none or
cascade=delete on the association to User.
(Also, as long as unsaved-value is correct, the save() will cascade to an
update() of the User, which is okay usually.)
I'm not 100% certain ... it would help if you would post a Hibernate
debug-level log
Did you set unsaved-value on HibernateAdministrator? The creating new rows
instead of updating existing rows thing is almost always a problem to do
with
unsaved-value being set wrongly...
Did you read the new
I INDEED need a many-to-one under bag!
My Top-level (not nested) bag table has a key column
and element column (integer). However the element
column is a foreign key (many-to-one) to another table
I'm sorry how is this not a many-to-many??
U.
You should use one-to-many or many-to-many
many-to-one makes no sense at all.
jiesheng zhang
Stack Trace?
---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
hibernate-devel mailing list
[EMAIL PROTECTED]
Very, very cool
One more request: is it possible to support this for package-visibility
methods by generating the MetaClass in the same package? (Might have to
have a different instance for each superclass in the hierarchy.)
It would be a little bit of work to integrate this into Hibernate,
Yeah, I'm not sure. I havn't had time to look at the
code myself, and no response from Max..
is he on holiday or something?
otisg
Wierd those methods are defined on the _handler_ class,
not the proxy interface itself.
And I didn't thing the proxies implement the interface of the
MethodInterceptor
H. HibernateProxy itself only declares writeReplace(). Do you mean
methods
that are coming from CGLIB, or are you referring to an older version of
Hibernate?
1. add the child element to the children set.
2. save the child explicitly by calling
Session.save(child).
Is it right?
If you have enabled cascades, you can skip (2).
By specifying readonly, in the code I have to
remember which set is readonly and I have to handle it
differently from
Just expecially for Max I have done some back-breaking coding (not really,
it was easy as pie) tonight and implemented the behavior he requested,
with respect to collections passed to update(). Collections now carry a
snapshot around with them so that we can update individual rows.
I had
You need to learn about the mysteries of the unsaved-value
attribute :)
Hibernate looks at the id value to determine if an object
discovered by cascade is new or not. So, if you have an
object with a Long identifier, set unsaved-value=null.
Note that another approach is to save() the Item
Here the children set in the Parent object is
readonly. Does it mean any modification to any Child
element in the Children set will not be persisted to
database( an violation of usual persistence by
reachability)? In
No, it is nothing to do with cascades.
this sense, the readonly applies
to the
Note also that there are actually some *advantages* to
a bag. We can add to a bag without initializing it.
So if you are mostly adding, a bag will be faster. If
you are mostly updating or removing, it will be
slower.
Note also that bags cannot add and remove elements
individually (this makes
Use a component mapping. (or a custom type)
Viktor Szathmary
The firstclass object may refer to the object that owns the component.
But no, you can't do something like
many-to-one name=parent class=MyComponentClass/
It seems like a lot of people are unhappy with the current
behaviour, so I'm open to suggestions. The easiest way
may simply be to give the collection a reference to its
snapshot that it can carry around with it and re-use in new
sessions.
An even simpler solution (for collections of immutable
Hibernate.custom(MyUserType.class)
Viktor Szathmary
From the Best Practices page:
Don't treat exceptions as recoverable
I think it would be helpful if Hibernate could guarantee in-memory state
at least for particular types of failures. In particular, Session.load
seems useful (and feasible?).
What is driving this request is a need for a
I just finished refactoring the .mapping package
that previously contained the logic for parsing
XML mapping documents into objects. That logic
is now extenalized, and the object model itself
cleaned up and exposed to the user via the
Configuration API. It is now finally possible
to meddle with
As promised, I have redesigned the Hibernate2 config API.
Usage now looks like:
SessionFactory sf = new Configuration()
.addResource(foo.hbm.xml)
.addClass(Bar.class)
.setProperties(props)
.setInterceptor( new MyInterceptor() )
.buildSessionFactory();
Alternatively, to use an XML
Heres a list of outstanding things for the next month or so:
* add @tag generation to hbm2java
* finish Middlegen plugin
* design new config API
I will be very busy for the immediate future, so if anyone is
interested in taking on any of these tasks, that would
be awesome. (They are all pretty
Agreed; I know quite a few people have told me of their
successful projects via private email, but would it be
possible to share these stories in a more public way?
Just today, someone was telling me how they have just
finished porting their entity-bean based project to
Hibernate to
Yes, which is problematic if you plan to use a common Hibernate
architecture
where the actual data model objects are exposed to the User Interface,
even in a three-tiered application. True transparent persistence lets you
do this in a philosophically pleasing way.
Don't Load More Data Than You Have To
But hey! thats only half the story! Also: Don't hit the database
more *often* than you have to. So you ALSO need outerjoin fetching
where appropriate!
Tell Me What Has Changed. Don't Make Me Look!
These arguments go to performance. So where are the
I suppose I'm overstating this case a little. I guess it might be
slightly helpful when deploying to a staging server with live
data. But I still don't see it really working in practice.
I am sceptical until I see something work in practice. I have never ever
worked on a site where, once a
Yes, I am very open to this; not only for instantiation, but
also for *proxy* instantiation. My motivation for this is
integration with AOP frameworks.
How I propose to do this is to add some more methods to
Interceptor in Hibernate2. (It is currently possible by
extending EntityPersister, but
Its perfectly possible to let the object decide with this new
functionality;
just define an interface with an isPersistent() method thats implemented
by the persistent classes. Let the interceptor call that method, if the
passed object implements the interface, otherwise return null and
Hibernate
Was I a little harsh on this guy? Sorry ;)
Just got your last point, cos it's only fair to point out that if this
is a Martin Fowler backed project, the chances are that this has been
developed in an Extreme manner, and probably has the easy support of
extreme programming in mind as one of
Yes, I'm glad you raised this Ara, there are a couple of different
things I've been speculating about here:
(1) An isDirty() interceptor callback, to allow an application to
implement its own dirty checking algorithm
(2) A new property attribute; update=never|auto, to declare
readonly
Mark, thanks for the patch - but would you please submit this to the
patch manager? I havn't been able to find time to review this, and I
don't want it to get lost in the list
sorry about that..
TIA
Gavin
Your code doesn't guarantee that close() gets called, if an exception
occurs during commit()
However, that is probably not the problem.
You could try disabling Hibernate's PreparedStatement cache (there is
mention of this
in the FAQ) which is quite aggressive by default. Also try disabling
Its a simple fix that I will apply tonight (AU time). I certainly already
plan a 1.2.3
release sometime soon but I'm not promising *that* for tonight.
I think its harder for XDoclet to stick to the kind of rapid release
schedule we have, simply because XDoclet must be MUCH harder to test.
You have a *lot* more platforms and platform-specific stuff going on
there.
Normally i can run tests against about 4 databases before a release
and be
Looks like you need to add a name attribute to the composite-id element,
to
specify which property holds the composite id.
Raible, Matt
I *think* that you would just have to set unsaved-value=none
for the composite-id children in order to convince Hibernate
to do an update rather than an insert.
(You also need to make sure that you are assigning unique
composite id values to all the children before flushing.)
null will not
[Note: It helps to view this email in monospace!]
I am part way through the job of refactoring Hibernate so that
SQL generation occurs in its own layer. The current internal
architecture is something along the lines of:
API Layer (interfaces only)
No; I've mentioned this a few times:
Hibernate never rendered any outerjoins in the first SQL statement
(ie. the one translated from HQL). Any objects that needed to be
fetched subsequently were certainly fetched using outerjoins. ie.
from foo in class Foo
turned into
select * from FOOS foo
)s.find(from p in Person where p.id =
42).list().iterator().next();
assertSame(p3,p4);
assertSame(p1,p3); // this one fails because of the copy-from-cache
semantics, right ? (which is ok)
s.flush();
s.close();
/max
- Original Message -
From: Gavin King [EMAIL PROTECTED
Inside a Session, Hibernate keeps a snapshot of the original state
of a collection and so can do removals/additions individually.
However, an object that came into the session via a call to update()
may have had all kind of things done to it (a PersistentCollection
completely replaced with a
Yep. id has a special interpretation in queries. I
Recommend against using it as the name of a regular
Property. (Fortunately it's the only special case.)
-Original Message-
From: Alejandro Revilla [mailto:[EMAIL PROTECTED]
Sent: Thursday, 16 January 2003 4:15 PM
To: [EMAIL PROTECTED]
Nah, not that smart ;)
I must admit that I never considered the possibility of such
a feature. Not sure if its feasible or not. Would certainly
Require a bit or work to implement.
-Original Message-
From: Schnitzer, Jeff [mailto:[EMAIL PROTECTED]
Sent: Thursday, 16 January 2003 5:11 PM
I think it might possibly be to do with your patch for long column names.
Try choosing much shorter column names and see what happens. (they are
distinguished only by the first three characters).
**
Any personal or sensitive
How can I delete relation-ship between objects in many-to-many
relationship, without deleting objects themselves with Hibernate?
//foo and bar are associated with session
foo.getBars().remove(bar);
bar.getFoos().remove(foo);
session.flush();
Oh, for about 10 minutes there was..
Max Rydahl Andersen
It seems there is an error in the current cvs?!
Woops. Theres no more NativeGenerator.
---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
I committed this to the Hibernate2 module last night, in fact. I have added
an interface called Configurable to the id package. Check that out to see
how it works. Hibernate2 will always use default constructors to
instantiate
id generators.
Its probably better to report these problems in the
XDoclet JIRA, since Konstantin and Joel are both
monitoring the Hibernate subproject
-Original Message-
From: Herve Tchepannou [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 7 January 2003 1:03 PM
To: [EMAIL PROTECTED]
Subject:
Check this out :)
-Original Message-
From: SourceForge.net [mailto:[EMAIL PROTECTED]
Sent: Monday, 6 January 2003 1:08 PM
To: [EMAIL PROTECTED]
Subject: [hibernate - Open Discussion] first crack at maven'ization
Read and respond to this message at:
Bauer [mailto:[EMAIL PROTECTED]
Sent: Monday, 6 January 2003 10:32 AM
To: [EMAIL PROTECTED]
Subject: Re: [Hibernate] logo
On 06 Jan (10:22), Gavin King wrote:
I'd love to have a logo but don't know anyone with the
requisite gfx
skills ...
Suggestions?
We have designers in our
I'd love to have a logo but don't know anyone with the
requisite gfx skills ...
Suggestions?
do you have a hibernate logo i can use on
http://boss.bekk.no/boss/middlegen/ when i commit the
hibernate plugin? the logo.jpg that figured on the hibenrate
site in pre-wiki days has gray
The old way I was doing it - now obviously kludgy - was to
create a new session factory everytime I initialized a DAO.
That would have been your problem. You *must* make sure that
ALL DAOs are using the same Session instance. (And
SessionFactory _should_ certainly be a singleton.)
Try something like:
Query q = sess.createQuery(from h in class Headend where h.id in
(:id_list) order by h.name);
q.setParameterList(id_list, headendIds);
List sorted = q.list();
Note that this is might not be very good if the id List is very long...
-Original Message-
From: Raible,
Sorry, thats nowhere near enough information. You should
show the code that uses the Hibernate Session and also
the full stack trace. A Hibernate TRACE-level log is also
sometimes useful.
-Original Message-
From: Laurent Fleuriot [mailto:[EMAIL PROTECTED]
Sent: Friday, 3 January 2003
Max, it would happen whenever you have a column name that approaches
the limit for the database. Hibernate needs to add an _0, etc at
the end when rendering aiases.
-Original Message-
From: max [mailto:[EMAIL PROTECTED]
Sent: Thursday, 2 January 2003 6:11 PM
To: Hibernate Mailing
Well, I imported the Hibernate2 sourcetree last night. Its in
its own module which means that for the next couple of months
we need to be *very* careful about handling patches. Bugfixes
and minor improvements must be applied against *both* trees.
(New features need only go into the Hibernate2
Yick. The biggest design problem with Hibernate at present is
the fact that we have no single class responsible for rendering
SQL. (As I have mentioned before, Hibernate models SQL
statements using StringBuffer...) So little things like this
that should be *very* easy turn out to be way more
IBM JVM returns reflected methods in the reverse order.
So if some test deosn't clean up after itself, it might
fail on one JVM but not the other :)
-Original Message-
From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 31 December 2002 12:16 AM
To: [EMAIL PROTECTED]
The name of the type is clob, and the expected property type
is java.sql.Clob. Note that there are restrictions upon what
you can do with Clobs (they can't be used outside of transaction,
for example).
You should also take notice of Hibernate.createClob().
-Original Message-
From: Ugo
My comments are now added in /italics/ on the page itself...
-Original Message-
From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 31 December 2002 7:16 AM
To: [EMAIL PROTECTED]
Subject: [Hibernate] Tools road map
I've been so insane to plot down a road-map for
property name=bar type=serializable
meta attribute=description
JavaDoc comment for getBar()
/meta
meta attribute=java-typejava.lang.Object/meta
/property
.
But this one ? Isn't this a bit cloudy
If I understand this correctly you
Have a look in the Patterns section of the wiki
at the Delegate pattern (and the discussion).
-Original Message-
From: Raible, Matt [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 31 December 2002 3:56 AM
To: '[EMAIL PROTECTED]'
Subject: [Hibernate] Combining 2 tables into 1 object
I
!
}
return results.toString();
}
Thanks,
Matt
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Gavin King
Sent: Sunday, December 29, 2002 4:09 AM
To: [EMAIL PROTECTED]
Subject: [Hibernate] CodeGenerator
Hi everyone,
I
The generated classes now have a dependency upon
commons-lang, which
doesn't bother me in the slightest, but other people may
have another
opinion.
Yes - me for one :) I would like to keep the generated code
as simple
as possible :) (but at the same time I like to broaden the
Ummm theres a bunch of things to get right and since I can't see your
mappings, I'm not sure which. However, you should check out the
functionality of:
* unsaved-value attribute of id
* cascade attribute of associations
* lazy attribute of collections
* proxy attribute of class, subclass,
This is a known limitation of the current Hibernate XDoclet
module. Now, I think XDoclet can support remote methods defined
on superclasses in its ejb module, so it must be possible to
add support for persistent properties defined on superclasses
to the Hibernate module.
Anyone know how to
Thanks Max; that is useful :)
-Original Message-
From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]
Sent: Monday, 23 December 2002 11:54 PM
To: [EMAIL PROTECTED]
Subject: Re: [Hibernate] Patch/Bug tracking suggestion...
14 hours and no objections - it is hereby done :)
Thanks. I will apply this asap :)
-Original Message-
From: Russell Smyth [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 24 December 2002 5:31 AM
To: Hibernate-Devel (E-mail)
Subject: [Hibernate] [PATCH] make Query.setMaxResults() work
for all databases
I have submitted a patch to
implementation than if
INSERTs were executed immediately. (And is also more efficent
with any id generation strategy other than native.)
-Original Message-
From: Mark Woon [mailto:[EMAIL PROTECTED]
Sent: Sunday, 22 December 2002 6:04 PM
To: Gavin King
Subject: Re: [Hibernate] New
Title: CarrierWave
Would someone have a look over this:
http://carrierwave.sourceforge.net/doc/Overview.html
and figure out exactly what it does and how it does it it has
a Hibernate persistence provider, apparently, and seems to
maybe help with the problem of retrieving a fully
that. In the
1.2 hibernate
didn't support generating schemas where multiple beans lived
in one table.
It would generate a create table for each bean resulting in
multiple create
tables for some tables. It looks like CVS has resolved this.
On Friday 20 December 2002 04:00 pm, Gavin King wrote
I agree with this. It is the resposibility of the middle tier
to fetch data. If it did not fulfil its part of the contract,
we can't just have the web tier suddenly open connections to
the database. That has all *kinds* of security implications.
I can't see any other decent way - the View
This one is going to be fuun :) (You didn't follow up on the discussion
on identity for these value beans - was it just to insane or ? :)
I think we need to maintain a strict distinction between value types
and entity types. These value beans shouldn't have any notion of
identity because they
Are you sure there is a column in the table named user_id??
This was the problem - it's named userid. Thanks for
putting an eye on this baby and giving me a hand!
NP.
Enjoy!
** CAUTION - Disclaimer **
This message may contain privileged and confidential
information. If
When I had a first look at the JDO API, I really liked
PersistenceManagerFactory
PersistenceManager
Hmmm I find Manager even more banal (and overloaded)
than Session. Anyway the Hibernate Session doesn't
seem to me to fit the description of Manager (which
carries connotations of
Hmm... I'm not sure I understand. Won't calling setString() negate
some the memory benefits of using a Clob (ie. not everything
needs to be
in memory)? I guess I'll wait and look at the code.
Only when first *creating* a Clob. When, presumably, you have the whole
thing in memory to
Title: patterns doco
I have started a new Wiki page in the community area where we can (collaboratively)
produce some documentation of common Hibernate design patterns. The page is
called workarounds at the moment, but it can be more general than that. I've
documented two patterns
It will happen immediately 1.2.1 is out the door. See my next post.
-Original Message-
From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]
Sent: Saturday, 21 December 2002 6:19 AM
To: Gavin King
Cc: hibernate list
Subject: Re: [Hibernate] Enhancements to the Hibernate
Xdoclet
Correct QL syntax is:
from user in class
com.cable.comcast.dmc.itd.cct.persistence.User
where user.username=?
:)
-Original Message-
From: Matt Raible [mailto:[EMAIL PROTECTED]
Sent: Saturday, 21 December 2002 6:21 AM
To: [EMAIL PROTECTED]
Subject: [Hibernate] Oracle error
I
Sorry, I don't know quite what you're referring to.
-Original Message-
From: cheeser [mailto:[EMAIL PROTECTED]
Sent: Saturday, 21 December 2002 5:56 AM
To: [EMAIL PROTECTED]
Subject: [Hibernate] multiple beans in one table
Was this fixed since 1.2? I was just about to
still getting the same
error. I'm guessing that my table name is irrelevant as long
as it's in the User.hbm.xml file.
Is there anyway to turn on debugging so I can see the SQL being sent?
Thanks,
Matt
-Original Message-
From: Gavin King [mailto:[EMAIL PROTECTED]
Sent
, by their
names, imply a long-lived, singleton-style object.
-Original Message-
From: Christian Bauer [mailto:[EMAIL PROTECTED]
Sent: Saturday, 21 December 2002 11:33 AM
To: [EMAIL PROTECTED]
Subject: Re: [Hibernate] Road Map
On 21 Dec (11:15), Gavin King wrote:
I suspect
No worries, its fixed...
-Original Message-
From: Ugo Cei [mailto:[EMAIL PROTECTED]
Sent: Thursday, 19 December 2002 7:41 PM
To: Gavin King
Subject: Re: [Hibernate] Missing semicolons in generated schema file
Gavin King wrote:
Woops, no, I didn't realise this (recent
Woops, no, I didn't realise this (recent functionality, btw)
would you submit a bug report and / or patch please. TIA.
-Original Message-
From: Ugo Cei [mailto:[EMAIL PROTECTED]
Sent: Thursday, 19 December 2002 2:41 AM
To: [EMAIL PROTECTED]
Subject: [Hibernate] Missing
Yes, please do that. I can't always integrate patches
right away.
-Original Message-
From: Konstantin Priblouda [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 18 December 2002 5:29 AM
To: Thomas Quas
Cc: hibernate-devel
Subject: Re: [Hibernate] SchemaExport Tool Mappings in Jar
Hi Konstantin,
it would be _so_ useful if you could write up a little bit of
documentation of this demo (which I notice is already recieving
some attention in the java.blogs community) so that I can link
to that from the Hibernate website.
Looks like I might be using XDoclet + Hibernate in a
Thanks :)
Have you tried running the Hibernate test suites to
see how much functionality can be supported on Access?
- Original Message -
From:
Pietro Polsinelli
To: [EMAIL PROTECTED]
Sent: Saturday, December 14, 2002 2:01
AM
Subject: [Hibernate] microsoft
You could easily implement this as an alternative Dialect (ie.
your second suggestion). HSQLDialect already uses integer as
the type for native id generation, so you can use that as a
model.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 11
2002 10:16 AM
To: Gavin King; Chris Winters
Cc: [EMAIL PROTECTED]
Subject: RE: [Hibernate] custom identifier class
hi,
On Tue, 10 Dec 2002 09:10:09 +1100, Gavin King
[EMAIL PROTECTED]
said:
This has been requested once before, and it would be very
trivial to add support
This has been requested once before, and it would be very
trivial to add support for a generator subelement of
composite-id. But theres always something very fishy
about using a generated (ie. synthetic) composite id. It
really makes no sense. It never even makes sense to have a
single
Comments inline
04:18:56,649 WARN
[JTATransactionFactory] No TransactionManagerLookup configured
(use of JCS read-write cache is not
recommended)
What is this setting. I get that warning even if I don't use JCS.
This is my hibernate.properties:
Just use an XML external entity to save yourself the copy/paste.
:)
-Original Message-
From: Aapo Laakkonen [mailto:[EMAIL PROTECTED]
Sent: Thursday, 5 December 2002 6:09 AM
To: [EMAIL PROTECTED]
Subject: [Hibernate] Global Components
I have need for global components. Here is
It isn't usually; not unless you have toplevel collections...
-Original Message-
From: Dave Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 4 December 2002 4:09 PM
To: [EMAIL PROTECTED]
Subject: [Hibernate] Re: Hibernate vs. Castor example
In the Hibernate implementation
Hmm - isn't this idiom inefficient ?
Doesn't parent.getChildren().add() (or any method on the collection)
result
in loading all the children ?
I am planning to make same small changes so that add() and remove()
*don't* force initialization of a readonly=true collection. I should
have done
401 - 500 of 573 matches
Mail list logo