From: Gavin K. <ga...@ap...> - 2002-09-19 14:52:06
|
Yeah, I have been trying to think of a ways to let you refer to the index of a collection element from inside the query language but I havn't really come up with anything. However, in this particular case, I'm not sure why you are using a query at all. List elements are returned sorted by index already; simply load the List itself.... I'm assuming you have another where condition that you aren't displaying to us. Unfortunately the new collection filtering functionality doesn't help either, because its also not aware of collections indexes. What might be possible would be to allow a special "index" identifier in collection filters, the same way we allow "this" to refer to the element. That would solve your problem, wouldn't it? ----- Original Message ----- From: Christoph Sturm To: hib...@li... Sent: Thursday, September 19, 2002 11:54 PM Subject: [Hibernate] how to get the name of the matchtable Hi All! I have 2 tables that have a n:m relation through a matchtable. table1 contains a definition like this: <list role="categories" table="tema_x_vtrm" lazy="true"> <key column="vtrmid"/> <index column="srtpos"/> <many-to-many class="at.mcg.clubticket.db.Tema" column="temaid"/> </list> and I'd like my elements to be sorted by srtpos. so I have to write select table from vtrm in class Table, cat in table.categories.elements where cat.id = 2 order by cat0_.srtpos, because hibernate joins the matchtable as "cat0_". Now I dont like this, because its an implementation detail that could change. I often think that I dont understand all parts of the query language, so maybe there's an easy solution to this, and someone can enlighten me ;) regards chris |
From: Christoph S. <ch...@mc...> - 2002-09-20 08:54:41
|
Hi Gavin! ----- Original Message ----- From: "Gavin King" <ga...@ap...> To: <hib...@li...> Sent: Thursday, September 19, 2002 4:52 PM Subject: Fw: [Hibernate] how to get the name of the matchtable > Yeah, I have been trying to think of a ways to let you refer to the index of > a collection element from inside the query language but I havn't really come > up with anything. However, in this particular case, I'm not sure why you are > using a query at all. List elements are returned sorted by index already; > simply load the List itself.... I'm assuming you have another where > condition that you aren't displaying to us. yeah, right :) > > Unfortunately the new collection filtering functionality doesn't help > either, because its also not aware of collections indexes. What might be > possible would be to allow a special "index" identifier in collection > filters, the same way we allow "this" to refer to the element. That would > solve your problem, wouldn't it? yeah, that would be fine. In some situations it would also be fine if I could just get the name of the match table with cat.match (just like cat.elements). I have a (legacy) database mapping here where the match tables contain all kinds of stuff (a sortpos, some date fields), that i could all use for order by, so it would be practical for me. One other thing, actually in the case of my select its not necessary at all to hit the cat table, the whole query could be resolved with just the matchtable and Table1. regards chris > > > ----- Original Message ----- > From: Christoph Sturm > To: hib...@li... > Sent: Thursday, September 19, 2002 11:54 PM > Subject: [Hibernate] how to get the name of the matchtable > > > Hi All! > > I have 2 tables that have a n:m relation through a matchtable. > > table1 contains a definition like this: > <list role="categories" table="tema_x_vtrm" lazy="true"> > <key column="vtrmid"/> > <index column="srtpos"/> > <many-to-many class="at.mcg.clubticket.db.Tema" > column="temaid"/> > </list> > > and I'd like my elements to be sorted by srtpos. > > so I have to write > select table from vtrm in class Table, cat in table.categories.elements > where cat.id = 2 order by cat0_.srtpos, > because hibernate joins the matchtable as "cat0_". Now I dont like this, > because its an implementation detail that could change. > > I often think that I dont understand all parts of the query language, so > maybe there's an easy solution to this, and someone can enlighten me ;) > > regards > chris > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > |
From: Gavin K. <ga...@ap...> - 2002-09-20 09:03:28
|
> In some situations it would also be fine if I could just get the name of the > match table with cat.match (just like cat.elements). I have a (legacy) > database mapping here where the match tables contain all kinds of stuff (a > sortpos, some date fields), that i could all use for order by, so it would > be practical for me. Hmmm this is something that never really occurred to me before. We have proper support for match tables by using <composite-element> mappings (a very powerful feature that I'm not sure people actually understand properly). However queries can never refer to fields of composite elements! Even with the new indexing [] stuff, I havn't (yet) implemented support for composite elements. |