RE: A couple of OSUser questions
"Brian Topping" <[email protected]> Sat, 6 Dec 2003 16:04:30 -0500
| Newsgroups | gmane.comp.java.open-symphony.devel |
|---|---|
| Message-ID | <[email protected]> |
I didn't make completely clear that I am a recent Hibernate convert. That's why I'm only now picking up the new OSUser code. So you'll have to excuse my current ignorance with composite keys under Hibernate. Konstantin checked in some example code into XDoclet samples for working with composites, but I haven't had time to play with it. If I remember correctly, it's using an object as the key. Clearly, it can't be a primitive type. From a legacy perspective, people converting their code (or their brains) from CMP are going to be using objects for their PKs. From my particular perspective, I have an entire schema full of object PKs. Setting the PK to zero for an unset PK doesn't get caught with an NPE when I get tired. When refactoring code (either manually or automagically), it's a lot harder to do so when the type is primitive versus object since object based code usually uses Object.equals() for comparison. But having said all that, I started out the conversation simply looking for a rationale for using primitives instead of objects. The moment one assumes... (cue sound of screetching tires and crunching metal...) Maybe there were some benefits to having primitives. Just trying to figure out what's up... best, -b -----Original Message----- From: Matthew E. Porter [mailto:[email protected]] Sent: Saturday, December 06, 2003 3:32 PM To: [email protected] Subject: Re: [Opensymphony-developers] A couple of OSUser questions Eric: You may be right. I was thinking we were talking about a composite id. So, back to Brian- what were you talking about? Also, if referring to long vs. Long, we are talking about 2 lines of code that check whether it is equal to 0 under saveUser and saveGroup. Cheers, matthew On Dec 6, 2003, at 2:21 PM, Eric Pugh wrote: I didn't realize we where talking about using <composite-id>, as I agree, we shouldn't use it. However, the magic of Hibernate is that if my user requires it, then in my implementation I can use a <composite-id> as long as my mapping loads instead of the default one. I think that all he meant was to use Long versus long as the id, which would still have the same mapping... Eric -----Original Message----- From:Matthew E. Porter [mailto:[email protected]] Sent:Saturday, December 06, 2003 7:56 PM To:[email protected] Subject:Re: [Opensymphony-developers] A couple of OSUser questions As quoting from Hibernate Documentation: "There is an alternative <composite-id>declaration to allow access to legacy data with composite keys. We strongly discourage its use for anything else." Can we please hold off applying the foreign PK patch until more people have chimed in? Cheers, matthew On Dec 6, 2003, at 1:44 PM, Eric Pugh wrote: Brian, I actually lean towards the PK being an object as well. I prefer to be able to know that getting a PK which is null means it hasn't been saved, versus knowing the 0 means unsaved. Especially as 0 is a perfectly good ID value! Which bug report was yours? I'll look at your patch and apply it, do you just want to one patch for all your changes? Eric -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Brian Topping Sent: Saturday, December 06, 2003 7:16 PM To: [email protected] Subject: [Opensymphony-developers] A couple of OSUser questions Hi all, Back from some extended time away from the keys. Doing some travel and carpentry and things of that nature. It's fun to be back. Hope all your holidays are going well. Just getting recent versions of the code down and was psyched to see Hibernate support in OSUser. I've been working a bit with it in the last 24 hours and filed one bug on it last night. I have the fixes for it, but it will take longer for someone to use them than it will for someone with IDEA and a RW connection to CVS to do the changes over again. It took me about 30 minutes on this side. The other one, I'm not so sure it's a bug or not, it smells a lot like it belongs in the space of "conventions" rather than bug. So I thought I would ask for some rationale. In the CMP world, primary keys are objects instead of primitives. I've been following that through to Hibernate since it looks like composite types require that as well. But BaseHibernateEntity defines the PK as a primitive long. Any comments on why this would be beneficial? Otherwise, my vote is to convert to object PKs and am happy to do the work on it. thanks, -b ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Opensymphony-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensymphony-developers <winmail.dat>