package POJOS; // Generated 24-Apr-2018 18:07:45 by Hibernate Tools 4.3.1
import java.util.HashSet; import java.util.Set;
/** * User generated by hbm2java */ public class User implements java.io.Serializable {
private Integer id;
private String fname;
private String lname;
private String email;
private String password;
private String mobile;
private String img;
private Integer logstatus;
private Set<MsgFromCustomer> msgFromCustomers = new HashSet<MsgFromCustomer>(0);
private Set<UserType> userTypes = new HashSet<UserType>(0);
private Set<BillingInfo> billingInfos = new HashSet<BillingInfo>(0);
private Set<Cart> carts = new HashSet<Cart>(0);
private Set<LoggDetails> loggDetailses = new HashSet<LoggDetails>(0);
private Set<Orders> orderses = new HashSet<Orders>(0);
private Set<Wishlish> wishlishes = new HashSet<Wishlish>(0);
private Set<Product> products = new HashSet<Product>(0);
private Set<Complaints> complaintses = new HashSet<Complaints>(0);
private Set<Invoice> invoices = new HashSet<Invoice>(0);
private Set<Rating> ratings = new HashSet<Rating>(0);
public User() {
}
public User(String fname, String lname, String email, String password, String mobile, String img, Integer logstatus, Set<MsgFromCustomer> msgFromCustomers, Set<UserType> userTypes, Set<BillingInfo> billingInfos, Set<Cart> carts, Set<LoggDetails> loggDetailses, Set<Orders> orderses, Set<Wishlish> wishlishes, Set<Product> products, Set<Complaints> complaintses, Set<Invoice> invoices, Set<Rating> ratings) {
this.fname = fname;
this.lname = lname;
this.email = email;
this.password = password;
this.mobile = mobile;
this.img = img;
this.logstatus = logstatus;
this.msgFromCustomers = msgFromCustomers;
this.userTypes = userTypes;
this.billingInfos = billingInfos;
this.carts = carts;
this.loggDetailses = loggDetailses;
this.orderses = orderses;
this.wishlishes = wishlishes;
this.products = products;
this.complaintses = complaintses;
this.invoices = invoices;
this.ratings = ratings;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFname() {
return this.fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return this.lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getMobile() {
return this.mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getImg() {
return this.img;
}
public void setImg(String img) {
this.img = img;
}
public Integer getLogstatus() {
return this.logstatus;
}
public void setLogstatus(Integer logstatus) {
this.logstatus = logstatus;
}
public Set<MsgFromCustomer> getMsgFromCustomers() {
return this.msgFromCustomers;
}
public void setMsgFromCustomers(Set<MsgFromCustomer> msgFromCustomers) {
this.msgFromCustomers = msgFromCustomers;
}
public Set<UserType> getUserTypes() {
return this.userTypes;
}
public void setUserTypes(Set<UserType> userTypes) {
this.userTypes = userTypes;
}
public Set<BillingInfo> getBillingInfos() {
return this.billingInfos;
}
public void setBillingInfos(Set<BillingInfo> billingInfos) {
this.billingInfos = billingInfos;
}
public Set<Cart> getCarts() {
return this.carts;
}
public void setCarts(Set<Cart> carts) {
this.carts = carts;
}
public Set<LoggDetails> getLoggDetailses() {
return this.loggDetailses;
}
public void setLoggDetailses(Set<LoggDetails> loggDetailses) {
this.loggDetailses = loggDetailses;
}
public Set<Orders> getOrderses() {
return this.orderses;
}
public void setOrderses(Set<Orders> orderses) {
this.orderses = orderses;
}
public Set<Wishlish> getWishlishes() {
return this.wishlishes;
}
public void setWishlishes(Set<Wishlish> wishlishes) {
this.wishlishes = wishlishes;
}
public Set<Product> getProducts() {
return this.products;
}
public void setProducts(Set<Product> products) {
this.products = products;
}
public Set<Complaints> getComplaintses() {
return this.complaintses;
}
public void setComplaintses(Set<Complaints> complaintses) {
this.complaintses = complaintses;
}
public Set<Invoice> getInvoices() {
return this.invoices;
}
public void setInvoices(Set<Invoice> invoices) {
this.invoices = invoices;
}
public Set<Rating> getRatings() {
return this.ratings;
}
public void setRatings(Set<Rating> ratings) {
this.ratings = ratings;
}
}
/////////////////////////userType from other table one to one //////////
package POJOS; // Generated 24-Apr-2018 18:07:45 by Hibernate Tools 4.3.1
/** * UserType generated by hbm2java */ public class UserType implements java.io.Serializable {
private Integer id;
private User user;
private String type;
private String status;
public UserType() {
}
public UserType(User user) {
this.user = user;
}
public UserType(User user, String type, String status) {
this.user = user;
this.type = type;
this.status = status;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
}
///////////////////and mycode is ////////////////////
public class loadUserDetails extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
String name1 = req.getParameter("name");
String email1 = req.getParameter("email");
String mobile1 = req.getParameter("mobile");
String type1 = req.getParameter("type");
String status1 = req.getParameter("status");
Session session = POJOS.NewHibernateUtil.getSessionFactory().openSession();
Criteria c = session.createCriteria(UserType.class);
c.add(Restrictions.or(
Restrictions.eq("type", "admin"),
Restrictions.eq("type", "customer")
));
if (!name1.equals("")) {
System.out.println(name1);
//HERE IS THE PROB..HOW CAN I GET THE PropertyName "fname"
//fname is in user class so can get it by using
//user.getfname(); how can i set this as PropertyName
c.add(Restrictions.eq(**user.fname**,name1));
}
if (!status1.equals("All")) {
c.add(Restrictions.eq("status", status1));
}
if(!type1.equals("All")){
c.add(Restrictions.eq("type", type1));
}
String no = req.getParameter("no");
//generate buttons
String pages = "";
int page = 1;
for (int i = 0; i < c.list().size(); i++) {
if (i % 3 == 0) {
pages += " <ul class=\"pagination\">\n"
+ " <li class=\"page-item\"><a class=\"w3-button w3-black\" onclick=\"loadUserDetails(" + i + ");\">" + page + "</a></li>\n"
+ "</ul>";
page++;
}
}
c.setFirstResult(Integer.parseInt(no));
c.setMaxResults(3);
List<UserType> u_list = c.list();
String userData = "";
for (UserType u : u_list) {
String state = "";
String status12 = "";
String typ = "";
String type12 = "";
if (u.getStatus().equals("Active")) {
state = "Active";
status12 = "Deactive";
} else {
state = "Deactive";
status12 = "Active";
}
if (u.getType().equals("admin")) {
typ = "admin";
type12 = "customer";
} else {
typ = "customer";
type12 = "admin";
}
userData += "<tr>\n"
+ " <td>" + u.getUser().getFname() + "</td>\n"
+ " <td>" + u.getUser().getLname() + "</td>\n"
+ " <td>" + u.getUser().getEmail() + "</td>\n"
+ " <td>" + u.getUser().getPassword() + "</td>\n"
+ " <td id=\"mobile\">" + u.getUser().getMobile() + "</td>\n"
+ " <td><select onchange=\"updateUserStatus("+u.getUser().getId()+");\" class=\"form-control\" id=\"status1\"><option>" + state + "</option><option>" + status12 + "</option></td>\n"
+ " <td><select onchange=\"updateUserDetails("+u.getUser().getId()+");\" class=\"form-control\" id=\"type1\"><option>" + typ + "</option><option>" + type12 + "</option></td>\n"
+ " </tr>";
}
resp.getWriter().write(pages + "," + userData);
} catch (Exception e) {
e.printStackTrace();
}
}
Aucun commentaire:
Enregistrer un commentaire