hibernate - Method to return a List to populate DataTable from a query containing inner join -


I have created a JSF project by using preprime components in Phlebps and by making the data firmness with being hibernate. In this project, for each model class, there are at least two views (xhtml page), a dao class and controller class. To return a list of items in the DAO, there is the following method which I use to populate the data cable. Below I am using to put snippets of DAO and XHTML pages. I'm using to populate the datatable.

Textboxaido.Java

  Public list & lt; Textobase & gt; Listener () {List & lt; Textobase & gt; listTextobase = null; String query = "include SELECT * tbl_textobase from internal to tbl_disciplina tbl_textobase.disciplina_textobase = tbl_disciplina.id_disciplina"; {Try this.manager.getTransaction ().) Start (); listTextobase = this.manager.createNativeQuery (query, new textboxes). GetClass ()). getResultList (); . Committed to this.manager.getTransaction (); } Hold (exception before) {listTextobase = null; . This.manager.getTransaction () rollback (); } Return list topbows; }   

TextBaseCentronJava

  Private list & lt; Assunto & gt; assuntos; Public listing & lt; Textobase & gt; GetTextosBases () {this.TtextosBases = textoBaseDao.listar (); Return textboxes; }   

Textobaselist.xhtml

  & lt; P: dataTable var = "textobase" value = "# {textobaseController.textosBases}" RowKey = "# {textobase.codigo_textobase}" selectionMode = "single" selection = "# {textobaseController.currentTextoBase}" style = "text-align : Center "PageRequence =" true "rows =" 10 "pageReimple =" {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {Next PG Link} {LastPageLink} "RowsPrefaceTemplate =" 5,10,15 "Lazy =" True "& gt; & Lt; F: Aspect Name = "Header" & gt; Texo Base & lt; Br / & gt; & Lt; / Ch: Aspect & gt; & Lt; P: column width = "50" headText = "CODGogo" type BY = "codego_textobase" id = "code_goTtebasebase" filterbivy = "code_o_texbase" filtermachmode = "included" & gt; # {Textobase.codigo_textobase} & lt; / P: column & gt; & Lt; P: column width = "650" header text = "texto" type type = "textto_textobase" id = "textto_textabase" filterbivy = "textoxtobbase" filtermachmode = "include" & gt; # {Textobase.titulo_textobase} & lt; / P: column & gt;   

It's all working perfectly so far. But I need to run a query that gives an object with the fields of the external table, which includes interiors to populate the datalet, which includes the fields of the external table, the query will look like this:

  string query = "selection"; Query + = "tbl_textobase.codigo_textobase,"; Query + = "tbl_textobase.titulo_textobase,"; Query + = "tbl_disciplina.nome_disciplina"; Query + = "FROM tbl_textobase"; Query + = "interconnect tbl_disciplina"; Query + = "tbl_textobase.disciplina_textobase = tbl_disciplina.id_disciplina";   

But as I return a list of text boxes, the fields of the external table have not returned to this list. So my question is:

What change should I make to return a list, along with the areas of the external table in the "list (") method and in my data tab, and which data can be populated properly?

some things ... < Pre> listTextobase = this.manager.createNativeQuery (query, new textboxes). GetClass ()). GetResultList ();

will create a mapping for the textobesh class ... then the simplest solution will be to add some transient features to the annotated class with @transient: i.e.:

  Private string attribute; ... @transence public string bring attitivis () {return.attribute; } ...   

Next, you may want to do this

  list & lt; Object [] & gt; List = (list & lt; object [] & gt;) unit manager .createNativeQuery (query) .getResultList ();   

Then you can repeat an object on the [] list. After this, your textobass class should have an N parameter constructor, where all parameters are examples of objects. Class, with transient features. You can do something like this:

  list & gt; TextoBase & gt; Results = New Arreelist & lt; TextoBase & gt; (); (Object [] for O list) {TextoBase line = new textbox (O [0], o [1], o [2], ...); result.add (aux); }   

Hope that helps Suerte

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -