Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem retrieving data from relational databse using persistence

 
jsfnewbiez noob
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm newbie here and also in jsf.

Recently, I have problem with my login page. I have database with table customer. What I want to do is when user enter username and password, it will go to another page. But, the problem is how to retrieve data from database. I have created persistence, but I still cant find the way how to retrieve data from database. Can someone help me? I'm using netbean for jsf.



This is the code generated by netbean when I choose "Entity Classes From Databse".

Just say I want to retrieve only one customer name. Can I simply write <hutputText value="#{Customer.name}"> like this?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't have many rules here at the JavaRanch, but we do insist that you use your Real Name and not some sort of "handle" or obvious alias. If you're not sure about this, see
http://www.javaranch.com/name.jsp .
 
caleb momanyi
Ranch Hand
Posts: 43
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after you create your entity classes eg Customer.java, you need to create session beans for the entity classes in another package say session classes. they have your entity class name and Facade suffix eg CustomerFacade.java

then in your servlet you reference the session beans with the annotation eg

@EJB
CustomerFacade customerFacade;

then in the method where you want to get the username and password you can use JPQL which is a query language for JPA this is where i am stuck too
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic