Reg: Grid DataSources

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Reg: Grid DataSources

srikaanth
Hi all,

Am working on a tapestry project. Am using grid to show table using
hibernate. I was able to show single table structure . But here i need
to join two table and show it in single table . Am using tapestry 5.3.
Is there any way to do or any addon avaliable or i need to created a new
structure on my own.

Reg

Srikaanth

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

Andreas Ernst
Am 18.03.14 05:39, schrieb srikaanth:
> Hi all,
>
> Am working on a tapestry project. Am using grid to show table using
> hibernate. I was able to show single table structure . But here i need
> to join two table and show it in single table . Am using tapestry 5.3.
> Is there any way to do or any addon avaliable or i need to created a new
> structure on my own.

The easiest way is to create a entity class from a sql view. Or you can
try this:

http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects

--
ae | Andreas Ernst | IT Spektrum
Postfach 5, 65612 Beselich
Schupbacher Str. 32, 65614 Beselich, Germany
Tel: +49-6484-91002 Fax: +49-6484-91003
[hidden email] | www.ae-online.de
www.tachyon-online.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

Lance Java
In hibernate, the HQL query "from Entity1 join Entity2" will return
List<Object[]> with Object[0] being Entity1 and Object[2] being Entity2.

You could use a custom BeanModel and PropertyConduits to look up properties
from the Object[] array.

See the demo here which uses a custom BeanModel and PropertyConduits to
generate a grid from a List<Map>
http://tapestry-stitch.uklance.cloudbees.net/mapgriddemo
Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

Lance Java
Another, possibly much simpler, approach is to wrap the
HibernateGridDataSource in a ConverterGridDataSource

The ConverterGridDataSource will take a GridDataSource and a Converter in
it's constructor and it will delegate through to another GridDataSource,
converting each row to a bean as it goes. Sounds easier / more maintainable
that BeanModel / PropertyConduits.
Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

srikaanth
Hi Lance,

               Thanks for the info i will work out as per your methods
and let u know.  This methods explain me a lot. Keep going your good work.



Reg

Srikaanth .k


On Tuesday 18 March 2014 01:10 PM, Lance Java wrote:
> Another, possibly much simpler, approach is to wrap the
> HibernateGridDataSource in a ConverterGridDataSource
>
> The ConverterGridDataSource will take a GridDataSource and a Converter in
> it's constructor and it will delegate through to another GridDataSource,
> converting each row to a bean as it goes. Sounds easier / more maintainable
> that BeanModel / PropertyConduits.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

Thiago H de Paula Figueiredo
In reply to this post by srikaanth
On Tue, 18 Mar 2014 01:39:28 -0300, srikaanth  
<[hidden email]> wrote:

> Hi all,

Hi!

> Am working on a tapestry project. Am using grid to show table using  
> hibernate. I was able to show single table structure . But here i need  
> to join two table and show it in single table . Am using tapestry 5.3.  
> Is there any way to do or any addon avaliable or i need to created a new  
> structure on my own.

Implement your own GridDataSource and write your own Hibernate query with  
the joins inside it.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

Thiago H de Paula Figueiredo
In reply to this post by Andreas Ernst
On Tue, 18 Mar 2014 02:50:36 -0300, Andreas Ernst <[hidden email]> wrote:

> The easiest way is to create a entity class from a sql view. Or you can  
> try this:
>
> http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects

Please do *not* use that (the code in that page). The approach is very bad  
and I explain why in that page, so I won't repeat it here. Do the right  
thing: write a ValueEncoder for your class (if it's a Hibernate entity,  
tapestry-hiberate does that for you automatically) and pass it to the  
Select's encoder parameter.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

srikaanth
In reply to this post by Thiago H de Paula Figueiredo
I have to join two table with different column name in it.

eg:

table_A ( id, name,age)
table_B ( id,sex,ph)

my need is this i have to show in grid like (name,age,sex,ph)  in a
single grid or table .

>> Am working on a tapestry project. Am using grid to show table using
>> hibernate. I was able to show single table structure . But here i
>> need to join two table and show it in single table . Am using
>> tapestry 5.3. Is there any way to do or any addon avaliable or i need
>> to created a new structure on my own.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Reg: Grid DataSources

Thiago H de Paula Figueiredo
On Tue, 18 Mar 2014 08:05:51 -0300, srikaanth  
<[hidden email]> wrote:

> I have to join two table with different column name in it.
>
> eg:
>
> table_A ( id, name,age)
> table_B ( id,sex,ph)
>
> my need is this i have to show in grid like (name,age,sex,ph)  in a  
> single grid or table .

The join itself is a Hibernate thing so it shouldn't be described here, a  
Tapestry mailing list. The Tapestry part, which is implementing a  
GridDataSource, was already described. Another tip: create a class to  
represent the result of the query. Your code will be more organized and  
Grid will work on it easily.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]