
Blockquote
I am new to java or hibernate...
Trying to get data from database...it does not pick up the data...
Authentication.java
public List<String> domains()
{ Query query = sessionFactory.getCurrentSession().createQuery("select distinct domainName from User");
List <String> domains = query.list(); return domains; }
Gatekeeper.java
public Domain getdomain()
{ logger.error("Starting getDomain()"); AuthenticationService auth = AppContext.getBean("auth"); Domain domainlist = new Domain(); domainlist.setDom(auth.domains()); return domainlist; }
Domain.java
public class Domain {
protected List<String> dom; public List<String> getDom() { return dom; } public void setDom(List<String> dom) { this.dom = dom; } @Override public String toString() { return "Domain [dom=" + dom + "]"; } }
Main.Class
Gatekeeper gateKeeper = new GatekeeperService().getGatekeeperPort(); Domain list = new Domain();
list = gateKeeper.getDomain();
System.out.println("The domain is " + list);
It gives null values even though the User table has data
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.