44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
|
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() + " )";
|
||
|
}
|
||
|
|
||
|
}
|