• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Problem retrieving data from relational databse using persistence

 
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 <h:outputText value="#{Customer.name}"> like this?
 
Saloon Keeper
Posts: 21981
150
Android Eclipse IDE Tomcat Server Redhat Java 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 .
 
Ranch Hand
Posts: 43
Netbeans IDE Firefox Browser Java
  • 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
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic