From 7f19b9e1ca7d41dd716bc2dc9e343cfa7ceff63e Mon Sep 17 00:00:00 2001 From: Yucheng Hu Date: Sun, 23 Jul 2017 11:07:43 -0400 Subject: [PATCH] =?UTF-8?q?Visa=20=E6=95=B0=E6=8D=AE=E5=BA=93=E5=B7=A5?= =?UTF-8?q?=E5=8E=82=E7=B1=BB=EF=BC=8C=E5=9C=A8=E8=BF=99=E4=B8=AA=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E8=8E=B7=E5=BE=97=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E5=92=8C=E4=BF=9D=E5=AD=98=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/factories/VisaFactory.java | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/usvisatrack/core/factories/VisaFactory.java b/core/src/main/java/com/usvisatrack/core/factories/VisaFactory.java index ddd93fb..8fd1c67 100644 --- a/core/src/main/java/com/usvisatrack/core/factories/VisaFactory.java +++ b/core/src/main/java/com/usvisatrack/core/factories/VisaFactory.java @@ -1,18 +1,10 @@ package com.usvisatrack.core.factories; -import java.util.ArrayList; -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.Transaction; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import com.usvisatrack.core.common.Factory; - +import com.usvisatrack.core.dao.model.Visa; /** * Item Data Factory @@ -21,12 +13,48 @@ import com.usvisatrack.core.common.Factory; * */ public class VisaFactory extends Factory { - private static final int LISTING_PAGE_SIZE = 20; - - public static final int DEFAULT_AUTH_EXPIRATION = 10; - private static Logger logger = LoggerFactory.getLogger(VisaFactory.class); - + private static final int LISTING_PAGE_SIZE = 20; + public static final int DEFAULT_AUTH_EXPIRATION = 10; + + /** + * Get VISA + * + * @param id + * @return + */ + public static Visa get(Long id) { + logger.debug("Get Visa OBJ by ID - [{}]", id); + Factory.beginTransaction(); + Visa item = null; + try { + item = Factory.get(Visa.class, id); + Factory.commitTransaction(); + } catch (Exception ex) { + item = null; + logger.error("Get Visa by item ID error", ex); + } finally { + Factory.rollbackTransaction(); + } + + return item; + } + + /** + * Save VISA + * + * @param visa + */ + public static void save(Visa visa) { + try { + Factory.beginTransaction(); + Factory.saveOrUpdate(visa); + Factory.commitTransaction(); + } catch (Exception ex) { + logger.error("Save Visa OBJ ERROR", ex); + Factory.rollbackTransaction(); + } + } } \ No newline at end of file