Thanks for the suggestions guys - most likely I'll stick to hibernate as
this gives me central control over how my users are represented and
used.
Currently there are not too many people registered on our server, but
we're looking at rollout in large numbers once we're past the test
stages - so I'll need to figure out how Hibernate works with this type
of query in the long run.
Thanks again!
-----Original Message-----
From: Jason Koeninger [mailto:jkoenin@jjcc.com]
Sent: 11 May 2006 16:13
To: xwiki-users(a)objectweb.org
Subject: Re: [xwiki-users] Joining two fields;
I'm no HQL expert, but I'm guessing you can do something like this:
select
firstname.value || ' ' || lastname.value from
BaseObject obj,
StringProperty firstname,
StringProperty lastname
where
obj.className='XWiki.XWikiUsers' and
firstname.id=obj.id and
firstname.name = 'first_name' and
lastname.id = obj.id and
lastname.name = 'last_name'
Untested so you may have to play around with it to get it to work.
Hopefully I'm not too far off the mark.
Also, depending on how your database's query optimizer works, a join
might perform better. Of course, that also depends on how Hibernate
translates the HQL to SQL. Hibernate *may* be smart enough to convert
this to a join in which case it's a non-issue.
Best Regards,
Jason Koeninger
J&J Computer Consulting
Mark Robinson wrote:
Hi Brandon.
No doubt there is a simple and elegant answer to your problem that
someone will suggest soon. I worked around a similar problem that I
needed to fix quickly by making the select straight html with a
Velocity loop over the the option tags.
That way you can still have your names and values as described.
Cheers,
Mark
On 11 May 2006, at 5:50 PM, Esbach, Brandon wrote:
> Hi all,
>
> I guess this is more a hibernate query than an Xwiki one, but here is
> what I'm trying to do:
> We use a simple project management class currently to keep track of
> projects/engineer assignments/etc - currently managers type in
> freeform names... as you could imagine this is a bit of a problem
with
> adding some more active content relating to the
user (we're adding a
> 'workdesk' feature on login so that engineers/managers can see what
> projects/tasks/etc are assigned to them, without having to browse
> around and search).
>
> What I thought of doing was adding a dropdown with the user details -
> allowing me to create a solid link between user
and project.
>
> Now here's the problem...
> I need to associate the firstname+lastname in the query - so that the
> manager/etc will pick a name they recognise
immediately, instead of
> relying on them to know login names.
>
> Initially, I had thought to use a Map or List to request multiple
> fields - but this does not seem to be understood by the renderer when
> it creates a list dropdown - I get immediate
errors
>
> Getting first name, no problem:
> select prop.value from BaseObject obj, StringProperty prop where
> obj.className='XWiki.XWikiUsers' and prop.id.id=obj.id and
> prop.name='first_name'
>
> EG output in the list:
> 'Brandon'
> 'UserXFirstName'
>
> Getting Last name, also no problem:
> select prop.value from BaseObject obj, StringProperty prop where
> obj.className='XWiki.XWikiUsers' and prop.id.id=obj.id and
> prop.name='last_name'
>
> EG output:
> 'Esbach'
> 'UserXLastName'
>
> Now it gets sticky. Join the two fields with a space between them,
> so that instead of 'Brandon' or 'Esbach' I get 'Brandon
Esbach'..
> This I cannot seem to figure out using Hibernate, so any
> hints/tips/suggestions would be appreciated.
>
>
> *Problem number 2:*
> Another small catch I have is mapping this entry so that I can query
> on it. Normally with data representation one would have a 'display'
> value and a 'link' value - kind of like the 'pretty name' and
'real
> name' facility of class objects; only the 'pretty name' gets shown
> when using automatic rendering - but the field is updated based on
> 'real name'. Erm. Hope that makes sense.
>
> eg if my Xwiki name is braesb, firstname Brandon, lastname Esbach I
> could have a list looking like this:
> 'Brandon Esbach'
> 'UserXFirstName UserXLastName'
> Selecting 'Brandon Esbach' would then look to my 'link' value of
> Xwiki.braesb, and store this with the record. Querying on this then
> becomes no problem - but can this be done in Xwiki?
>
> /Brandon Esbach/
> /Software Engineer/
> /M/A-Com Eurotec Operations/
> /LoughMahon Technology Park,/
> /Skehard Road,/
> /Blackrock,/
> /Cork, Ireland/
> /Tel +353 21 4808305/
>
>
> --
> You receive this message as a subscriber of the
> xwiki-users(a)objectweb.org <mailto:xwiki-users@objectweb.org> mailing
list.
To
unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/wws
----------------------------------------------------------------------
--
--
You receive this message as a subscriber of the
xwiki-users(a)objectweb.org mailing
list.
To unsubscribe:
mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/wws