提交按照数据库更新的所有数据库 ORM 对象
This commit is contained in:
parent
2d416b95c4
commit
8c025667bb
|
@ -1,42 +1,25 @@
|
||||||
|
|
||||||
package com.usvisatrack.core.dao.model;
|
package com.usvisatrack.core.dao.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.usvisatrack.core.common.DataObject;
|
import com.usvisatrack.core.common.DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merchant generated by hbm2java
|
* User ORM
|
||||||
*/
|
*
|
||||||
public class User extends DataObject implements java.io.Serializable {
|
* @author YuCheng
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -8094138967079219902L;
|
public class User extends DataObject {
|
||||||
|
|
||||||
private String email;
|
|
||||||
private String userName;
|
private String userName;
|
||||||
private String password;
|
private String password;
|
||||||
private String apiKey;
|
private String email;
|
||||||
private String apiToken;
|
private Date dateRegistered;
|
||||||
private String firstName;
|
|
||||||
private String lirstName;
|
|
||||||
private Date dateReg;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
}
|
this.dateRegistered = new Date();
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
|
@ -55,46 +38,20 @@ public class User extends DataObject implements java.io.Serializable {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getApiKey() {
|
public String getEmail() {
|
||||||
return apiKey;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApiKey(String apiKey) {
|
public void setEmail(String email) {
|
||||||
this.apiKey = apiKey;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getApiToken() {
|
public Date getDateRegistered() {
|
||||||
return apiToken;
|
return dateRegistered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApiToken(String apiToken) {
|
public void setDateRegistered(Date dateRegistered) {
|
||||||
this.apiToken = apiToken;
|
this.dateRegistered = dateRegistered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFirstName() {
|
|
||||||
return firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirstName(String firstName) {
|
|
||||||
this.firstName = firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLirstName() {
|
|
||||||
return lirstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLirstName(String lirstName) {
|
|
||||||
this.lirstName = lirstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDateReg() {
|
|
||||||
return dateReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDateReg(Date dateReg) {
|
|
||||||
this.dateReg = dateReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,10 @@ import com.usvisatrack.core.common.data.VisaStatus;
|
||||||
*/
|
*/
|
||||||
public class Visa extends DataObject {
|
public class Visa extends DataObject {
|
||||||
|
|
||||||
private String ds160Code;
|
private User user;
|
||||||
private USEmbassy usEmbassy;
|
private USEmbassy usEmbassy;
|
||||||
private VisaClass visaClass;
|
private VisaClass visaClass;
|
||||||
|
private String ds160Code;
|
||||||
private VisaEntry visaEntry;
|
private VisaEntry visaEntry;
|
||||||
private VisaStatus visaStatus;
|
private VisaStatus visaStatus;
|
||||||
private String major;
|
private String major;
|
||||||
|
@ -31,6 +32,14 @@ public class Visa extends DataObject {
|
||||||
super.setModifyDate(date);
|
super.setModifyDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDs160Code() {
|
public String getDs160Code() {
|
||||||
return ds160Code;
|
return ds160Code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package com.usvisatrack.core.factories;
|
package com.usvisatrack.core.factories;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.Transaction;
|
|
||||||
import org.hibernate.criterion.Order;
|
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.usvisatrack.core.common.Factory;
|
import com.usvisatrack.core.common.Factory;
|
||||||
|
import com.usvisatrack.core.dao.model.USEmbassy;
|
||||||
|
import com.usvisatrack.core.dao.model.User;
|
||||||
|
import com.usvisatrack.core.dao.model.Visa;
|
||||||
|
|
||||||
public class UserFactory {
|
public class UserFactory {
|
||||||
private static final int LISTING_PAGE_SIZE = 20;
|
private static final int LISTING_PAGE_SIZE = 20;
|
||||||
|
@ -18,6 +16,58 @@ public class UserFactory {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(UserFactory.class);
|
private static Logger logger = LoggerFactory.getLogger(UserFactory.class);
|
||||||
|
|
||||||
|
public static User get(Long id) {
|
||||||
|
logger.debug("Get User OBJ by ID - [{}]", id);
|
||||||
|
Factory.beginTransaction();
|
||||||
|
User user = null;
|
||||||
|
try {
|
||||||
|
user = Factory.get(User.class, id);
|
||||||
|
Factory.commitTransaction();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Get User by user ID error", ex);
|
||||||
|
} finally {
|
||||||
|
Factory.rollbackTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by userName
|
||||||
|
*
|
||||||
|
* @param userName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static User get(String userName) {
|
||||||
|
logger.debug("Search USEmbassy - [{}]/[{}]", userName);
|
||||||
|
try {
|
||||||
|
Factory.beginTransaction();
|
||||||
|
Criteria criteria = Factory.createCriteria(User.class);
|
||||||
|
criteria.add(Restrictions.eq("userName", userName));
|
||||||
|
criteria.setMaxResults(1);
|
||||||
|
return (User) criteria.uniqueResult();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Search USEmbassy data error", ex);
|
||||||
|
} finally {
|
||||||
|
Factory.commitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
*/
|
||||||
|
public static void save(User user) {
|
||||||
|
try {
|
||||||
|
Factory.beginTransaction();
|
||||||
|
Factory.saveOrUpdate(user);
|
||||||
|
Factory.commitTransaction();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Save USER OBJ ERROR", ex);
|
||||||
|
Factory.rollbackTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.usvisatrack.core.common.Factory;
|
import com.usvisatrack.core.common.Factory;
|
||||||
|
import com.usvisatrack.core.dao.model.CheckeeVisa;
|
||||||
import com.usvisatrack.core.dao.model.Visa;
|
import com.usvisatrack.core.dao.model.Visa;
|
||||||
import com.usvisatrack.core.dao.model.VisaClass;
|
import com.usvisatrack.core.dao.model.VisaClass;
|
||||||
|
|
||||||
|
@ -45,6 +46,34 @@ public class VisaFactory extends Factory {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Visa OBJ
|
||||||
|
*
|
||||||
|
* @param checkkeID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Visa getVisaFromCheckee(Long checkkeID) {
|
||||||
|
logger.debug("Get Visa OBJ by checkkeID - [{}]", checkkeID);
|
||||||
|
Visa visa = null;
|
||||||
|
CheckeeVisa checkeeVisa = null;
|
||||||
|
|
||||||
|
Factory.beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
checkeeVisa = Factory.get(CheckeeVisa.class, checkkeID);
|
||||||
|
if (checkeeVisa != null) {
|
||||||
|
visa = get(checkeeVisa.getVisaID());
|
||||||
|
}
|
||||||
|
Factory.commitTransaction();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Get Visa by item ID error", ex);
|
||||||
|
} finally {
|
||||||
|
Factory.rollbackTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
return visa;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
@ -80,4 +109,15 @@ public class VisaFactory extends Factory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void save(CheckeeVisa checkeeVisa) {
|
||||||
|
try {
|
||||||
|
Factory.beginTransaction();
|
||||||
|
Factory.saveOrUpdate(checkeeVisa);
|
||||||
|
Factory.commitTransaction();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Save CheckeeVisa OBJ ERROR", ex);
|
||||||
|
Factory.rollbackTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,34 +3,26 @@
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping package="com.usvisatrack.core.dao.model">
|
<hibernate-mapping package="com.usvisatrack.core.dao.model">
|
||||||
<class name="User" table="user" catalog="ntc_usvisatrack">
|
<class name="User" table="user" catalog="northtecom_usvisatrack">
|
||||||
<id name="id" type="java.lang.Long">
|
<id name="id" type="long">
|
||||||
<column name="uid" />
|
<column name="user_id" />
|
||||||
<generator class="identity" />
|
<generator class="identity" />
|
||||||
</id>
|
</id>
|
||||||
|
|
||||||
<property name="email" type="string">
|
|
||||||
<column name="email" />
|
|
||||||
</property>
|
|
||||||
|
|
||||||
<property name="userName" type="string">
|
<property name="userName" type="string">
|
||||||
<column name="username" />
|
<column name="username" length="64" />
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<property name="password" type="string">
|
<property name="password" type="string">
|
||||||
<column name="password" />
|
<column name="password" length="255" />
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<property name="apiKey" type="string">
|
<property name="email" type="string">
|
||||||
<column name="api_key" />
|
<column name="email" length="255" />
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<property name="apiToken" type="string">
|
<property name="dateRegistered" type="timestamp">
|
||||||
<column name="api_token" />
|
<column name="date_registered" />
|
||||||
</property>
|
|
||||||
|
|
||||||
<property name="dateReg" type="timestamp">
|
|
||||||
<column name="date_reg" />
|
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
|
|
@ -9,13 +9,18 @@
|
||||||
<generator class="identity" />
|
<generator class="identity" />
|
||||||
</id>
|
</id>
|
||||||
|
|
||||||
<property name="ds160Code" type="string">
|
|
||||||
<column name="ds160_code" length="16" />
|
<many-to-one class="com.usvisatrack.core.dao.model.User" fetch="select" insert="true" name="user" update="true" lazy="proxy">
|
||||||
</property>
|
<column name="user_fk" not-null="true" />
|
||||||
|
</many-to-one>
|
||||||
|
|
||||||
<many-to-one class="com.usvisatrack.core.dao.model.USEmbassy" name="usEmbassy" column="us_embassy_fk" fetch="join" />
|
<many-to-one class="com.usvisatrack.core.dao.model.USEmbassy" name="usEmbassy" column="us_embassy_fk" fetch="join" />
|
||||||
<many-to-one class="com.usvisatrack.core.dao.model.VisaClass" name="visaClass" column="visa_class_fk" fetch="join" />
|
<many-to-one class="com.usvisatrack.core.dao.model.VisaClass" name="visaClass" column="visa_class_fk" fetch="join" />
|
||||||
|
|
||||||
|
<property name="ds160Code" type="string">
|
||||||
|
<column name="ds160_code" length="16" />
|
||||||
|
</property>
|
||||||
|
|
||||||
<property name="visaStatus" column="visa_status">
|
<property name="visaStatus" column="visa_status">
|
||||||
<type name="org.hibernate.type.EnumType">
|
<type name="org.hibernate.type.EnumType">
|
||||||
<param name="enumClass">com.usvisatrack.core.common.data.VisaStatus</param>
|
<param name="enumClass">com.usvisatrack.core.common.data.VisaStatus</param>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
<property name="hibernate.c3p0.validate">true</property>
|
<property name="hibernate.c3p0.validate">true</property>
|
||||||
|
|
||||||
<!-- HBMs -->
|
<!-- HBMs -->
|
||||||
|
<mapping resource="hbm/CheckeeVisa.hbm.xml" />
|
||||||
<mapping resource="hbm/USEmbassy.hbm.xml" />
|
<mapping resource="hbm/USEmbassy.hbm.xml" />
|
||||||
<mapping resource="hbm/User.hbm.xml" />
|
<mapping resource="hbm/User.hbm.xml" />
|
||||||
<mapping resource="hbm/Visa.hbm.xml" />
|
<mapping resource="hbm/Visa.hbm.xml" />
|
||||||
|
|
Loading…
Reference in New Issue