Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate querying issue
    primarykey
    data
    text
    <p>I have the following code on the webservice that uses Hibernate</p> <pre><code>Session session = ICDBHibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); User user = (User) session.load(User.class, userid); userId is a paramter sent from the client. User class package com.icdb.data; import java.util.Date; import java.util.HashSet; import java.util.Set; public class User implements java.io.Serializable { private Integer userid; private String username; private String email; private String password; private String firstname; private String lastname; // private String streetaddress; // private String city; // private String phone; private String state; private String country; private Date birthdate; // private String zipcode; private Set usersesForFavoriteuser = new HashSet(0); private Set recipetipses = new HashSet(0); private Set recipeses = new HashSet(0); private Set recipepictureses = new HashSet(0); private Set onlineuserses = new HashSet(0); private Set generaltipses = new HashSet(0); private Set usersesForFollowinguser = new HashSet(0); private Set recipereviewses = new HashSet(0); public User() { } public User( String username, String password, String email, String firstname, String lastname, // String streetaddress, // String city, // String phone, String state, String country, Date birthdate ) // String zipcode ) { this.username = username; this.password = password; this.email = email; this.firstname = firstname; this.lastname = lastname; // this.streetaddress = streetaddress; // this.city = city; // this.phone = phone; this.state = state; this.country = country; this.birthdate = birthdate; // this.zipcode = zipcode; } public User( String username, String password, String email, String firstname, String lastname, // String streetaddress, // String city, String phone, // String state, // String country, // String email, Date birthdate, // String zipcode, Set usersesForFavoriteuser, Set recipetipses, Set recipeses, Set recipepictureses, Set onlineuserses, Set generaltipses, Set usersesForFollowinguser, Set recipereviewses ) { this.username = username; this.password = password; this.email = email; this.firstname = firstname; this.lastname = lastname; // this.streetaddress = streetaddress; // this.city = city; // this.phone = phone; this.state = state; this.country = country; this.birthdate = birthdate; // this.zipcode = zipcode; this.usersesForFavoriteuser = usersesForFavoriteuser; this.recipetipses = recipetipses; this.recipeses = recipeses; this.recipepictureses = recipepictureses; this.onlineuserses = onlineuserses; this.generaltipses = generaltipses; this.usersesForFollowinguser = usersesForFollowinguser; this.recipereviewses = recipereviewses; } public Integer getUserid() { return this.userid; } public void setUserid(Integer userid) { this.userid = userid; } public String getUsername() { return this.username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public String getFirstname() { return this.firstname; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getLastname() { return this.lastname; } public void setLastname(String lastname) { this.lastname = lastname; } // public String getStreetaddress() { // return this.streetaddress; // } // public void setStreetaddress(String streetaddress) { // this.streetaddress = streetaddress; // } // public String getCity() { // return this.city; // } // public void setCity(String city) { // this.city = city; // } // public String getPhone() { // return this.phone; // } // public void setPhone(String phone) { // this.phone = phone; // } public String getState() { return this.state; } public void setState(String state) { this.state = state; } public String getCountry() { return this.country; } public void setCountry(String country) { this.country = country; } public String getEmail() { return this.email; } public void setEmail(String email) { this.email = email; } public Date getBirthdate() { return this.birthdate; } public void setBirthdate(Date birthdate) { this.birthdate = birthdate; } // public String getZipcode() { // return this.zipcode; // } // public void setZipcode(String zipcode) { // this.zipcode = zipcode; // } public Set getUsersesForFavoriteuser() { return this.usersesForFavoriteuser; } public void setUsersesForFavoriteuser(Set usersesForFavoriteuser) { this.usersesForFavoriteuser = usersesForFavoriteuser; } public Set getRecipetipses() { return this.recipetipses; } public void setRecipetipses(Set recipetipses) { this.recipetipses = recipetipses; } public Set getRecipeses() { return this.recipeses; } public void setRecipeses(Set recipeses) { this.recipeses = recipeses; } public Set getRecipepictureses() { return this.recipepictureses; } public void setRecipepictureses(Set recipepictureses) { this.recipepictureses = recipepictureses; } public Set getOnlineuserses() { return this.onlineuserses; } public void setOnlineuserses(Set onlineuserses) { this.onlineuserses = onlineuserses; } public Set getGeneraltipses() { return this.generaltipses; } public void setGeneraltipses(Set generaltipses) { this.generaltipses = generaltipses; } public Set getUsersesForFollowinguser() { return this.usersesForFollowinguser; } public void setUsersesForFollowinguser(Set usersesForFollowinguser) { this.usersesForFollowinguser = usersesForFollowinguser; } public Set getRecipereviewses() { return this.recipereviewses; } public void setRecipereviewses(Set recipereviewses) { this.recipereviewses = recipereviewses; } } </code></pre> <p>also userId defined in the .hbm.xml as</p> <pre><code> &lt;id name="userid" type="java.lang.Integer"&gt; &lt;column name="userid"/&gt; &lt;generator class="identity"/&gt; &lt;/id&gt; </code></pre> <p>So we have a table of users and another tables that its FK is userId.</p> <p>I need to update the code to handle the request with a username - and then retrieve the userId instead of the mentioned code of the webservice.</p> <p>Please help :)</p> <p>Yoav</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload