Skip to Main Content

JSF CRUD Webapplication Netbeans 15. Need to display Name instead of ID

User_W7RU9Nov 20 2022 — edited Nov 20 2022

I am using netbeans and new to JSf and Primefaces.
The CRUD Webapplication is created using Netbeans 15 - created tables, generated entities from database, created JSF using the entities (Maven Framework).
Table 1) Customer - CustID, CustName, CenterID
Table 2) Center - CenterID, CenterName

Question 1)
In the Customer LIST page, I can see the correct CenterID. I want to replace the centerID with CenterName. How do it exactly using this framework. I am aware of table joins. But not sure what is the best way to change the model and display in view has NamedQueries:
@NamedQuery(name = "BCustomerMst.findAll", query = "SELECT b FROM BCustomerMst b")
@NamedQuery(name = "BCentreMst.findAll", query = "SELECT b.centerName FROM BCentreMst b"),

List.html is iterating items as follows:
<p:dataTable id="datalist" value="#{bCustomerMstController.items}" var="item"
selectionMode="single" selection="#{bCustomerMstController.selected}"

<h:outputText value="#{item.centerID}"/>
I want this centerID replaced with centerName

Question 2)
There are multiple named queries. The first one is picked up by List to display the data. How to select the Other Queries to show the data in LIST? I am unable to understand how the first one is selected by default. Missing something.

Can anyone help please?

Post Details
Added on Nov 20 2022