hs.hsadmin/hsarback/src/de/hsadmin/mods/db/MySqlUser.java

44 lines
1.2 KiB
Java
Raw Normal View History

2011-03-22 23:02:06 +01:00
package de.hsadmin.mods.db;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "MySqlUsers")
@Table(name = "database_user")
@SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq")
@EntityInfo(name = "MySQL Konto")
@SearchFilter("instance = 'mysql' AND ("
+ " pac = :loginUserPac OR "
+ " pac.customer.memberCode = :loginUserName )")
public class MySqlUser extends DatabaseUser implements Serializable {
private static final long serialVersionUID = 6218494776881999478L;
public static String createQueryFromStringKey(String humanKey) {
return "name='" + humanKey + "' AND instance='mysql'";
}
public MySqlUser() {
setInstance("mysql");
}
public MySqlUser(Pac pac, String name, String password) {
super("mysql", pac, name, password);
}
/**
* query restriction for access control
*/
public static String restriction() {
return "instance='mysql' AND ( " + DatabaseUser.restriction() + " )";
}
}