Example usage for org.hibernate.type StandardBasicTypes DATE

List of usage examples for org.hibernate.type StandardBasicTypes DATE

Introduction

In this page you can find the example usage for org.hibernate.type StandardBasicTypes DATE.

Prototype

DateType DATE

To view the source code for org.hibernate.type StandardBasicTypes DATE.

Click Source Link

Document

The standard Hibernate type for mapping java.util.Date ( java.sql.Date ) to JDBC java.sql.Types#DATE DATE .

Usage

From source file:com.Module.BarModule.java

public static List getReplyOwnerInfo(String reply_id) {
    Session s = HibernateUtil.currentSession();
    HibernateUtil.beginTransaction();//from   w  ww  .j ava2 s. c o m
    String sql = "Select user_name,reply.user_id,post_date from reply,user"
            + " where reply.user_id = user.user_id and reply_id = " + reply_id;
    //      ArrayList<String> get = new ArrayList<String>();
    //      get.add("user_name");
    //      get.add("String");
    //      get.add("user_id");
    //      get.add("int");
    //      get.add("post_date");
    //      get.add("date");
    List list = s.createSQLQuery(sql).addScalar("user_name", StandardBasicTypes.STRING)
            .addScalar("user_id", StandardBasicTypes.INTEGER).addScalar("post_date", StandardBasicTypes.DATE)
            .list();
    HibernateUtil.commitTransaction();//??
    HibernateUtil.closeSession();
    return list;
}

From source file:com.mysema.query.jpa.support.TeradataDialect.java

License:Open Source License

/**
 * Constructor// w  w w.j  a  v a2s  .co  m
 */
public TeradataDialect() {
    super();
    // registerColumnType data types
    registerColumnType(Types.NUMERIC, "NUMERIC($p,$s)");
    registerColumnType(Types.DOUBLE, "DOUBLE PRECISION");
    registerColumnType(Types.BIGINT, "NUMERIC(18,0)");
    registerColumnType(Types.BIT, "BYTEINT");
    registerColumnType(Types.TINYINT, "BYTEINT");
    registerColumnType(Types.VARBINARY, "VARBYTE($l)");
    registerColumnType(Types.BINARY, "BYTEINT");
    registerColumnType(Types.LONGVARCHAR, "LONG VARCHAR");
    registerColumnType(Types.CHAR, "CHAR(1)");
    registerColumnType(Types.DECIMAL, "DECIMAL");
    registerColumnType(Types.INTEGER, "INTEGER");
    registerColumnType(Types.SMALLINT, "SMALLINT");
    registerColumnType(Types.FLOAT, "FLOAT");
    registerColumnType(Types.VARCHAR, "VARCHAR($l)");
    registerColumnType(Types.DATE, "DATE");
    registerColumnType(Types.TIME, "TIME");
    registerColumnType(Types.TIMESTAMP, "TIMESTAMP");
    registerColumnType(Types.BOOLEAN, "BYTEINT"); // hibernate seems to
                                                  // ignore this type...
    registerColumnType(Types.BLOB, "BLOB");
    registerColumnType(Types.CLOB, "CLOB");

    registerFunction("year", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(year from ?1)"));
    registerFunction("length", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "character_length(?1)"));
    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "(", "||", ")"));
    registerFunction("substring",
            new SQLFunctionTemplate(StandardBasicTypes.STRING, "substring(?1 from ?2 for ?3)"));
    registerFunction("locate", new SQLFunctionTemplate(StandardBasicTypes.STRING, "position(?1 in ?2)"));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.STRING, "?1 mod ?2"));
    registerFunction("str", new SQLFunctionTemplate(StandardBasicTypes.STRING, "cast(?1 as varchar(255))"));

    // bit_length feels a bit broken to me. We have to cast to char in order
    // to
    // pass when a numeric value is supplied. But of course the answers
    // given will
    // be wildly different for these two datatypes. 1234.5678 will be 9
    // bytes as
    // a char string but will be 8 or 16 bytes as a true numeric.
    // Jay Nance 2006-09-22
    registerFunction("bit_length",
            new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "octet_length(cast(?1 as char))*4"));

    // The preference here would be
    // SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp(?1)",
    // false)
    // but this appears not to work.
    // Jay Nance 2006-09-22
    registerFunction("current_timestamp",
            new SQLFunctionTemplate(StandardBasicTypes.TIMESTAMP, "current_timestamp"));
    registerFunction("current_time", new SQLFunctionTemplate(StandardBasicTypes.TIME, "current_time"));
    registerFunction("current_date", new SQLFunctionTemplate(StandardBasicTypes.DATE, "current_date"));
    // IBID for current_time and current_date

    registerKeyword("account");
    registerKeyword("alias");
    registerKeyword("class");
    registerKeyword("column");
    registerKeyword("first");
    registerKeyword("map");
    registerKeyword("month");
    registerKeyword("password");
    registerKeyword("role");
    registerKeyword("summary");
    registerKeyword("title");
    registerKeyword("type");
    registerKeyword("value");
    registerKeyword("year");

    // Tell hibernate to use getBytes instead of getBinaryStream
    getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "false");
    // No batch statements
    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
}

From source file:com.processpuzzle.persistence.typemapping.domain.TimePointToDateMapping.java

License:Open Source License

public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner)
        throws HibernateException, SQLException {
    java.util.Date savedDate = (Date) StandardBasicTypes.DATE.nullSafeGet(resultSet, names[0], session);
    return new TimePoint(savedDate);
}

From source file:com.processpuzzle.persistence.typemapping.domain.TimePointToDateMapping.java

License:Open Source License

public void nullSafeSet(PreparedStatement statement, Object objectToSave, int index, SessionImplementor session)
        throws HibernateException, SQLException {
    if (objectToSave == null) {
        statement.setNull(index + 1, Types.DATE);
    } else {/*from w ww.j a  v a 2s .c o m*/
        StandardBasicTypes.DATE.nullSafeSet(statement, ((TimePoint) objectToSave).getValue(), index, session);
    }
}

From source file:com.processpuzzle.persistence.typemapping.domain.TimePointToDateMapping.java

License:Open Source License

public Type[] getPropertyTypes() {
    return new Type[] { StandardBasicTypes.DATE };
}

From source file:com.syndiceo.MySQLDialect.java

License:Open Source License

public MySQLDialect() {
    super();/*  w w w. j  a va 2  s  .c  o m*/
    registerColumnType(Types.BIT, "bit");
    registerColumnType(Types.BIGINT, "int8");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.CHAR, "char(1)");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.DOUBLE, "double precision");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.VARBINARY, "longblob");
    registerColumnType(Types.VARBINARY, 16777215, "mediumblob");
    registerColumnType(Types.VARBINARY, 65535, "blob");
    registerColumnType(Types.VARBINARY, 255, "tinyblob");
    registerColumnType(Types.BINARY, "binary($l)");
    registerColumnType(Types.LONGVARBINARY, "longblob");
    registerColumnType(Types.LONGVARBINARY, 16777215, "mediumblob");
    registerColumnType(Types.NUMERIC, "decimal($p,$s)");
    registerColumnType(Types.BLOB, "longblob");
    //      registerColumnType( Types.BLOB, 16777215, "mediumblob" );
    //      registerColumnType( Types.BLOB, 65535, "blob" );
    registerColumnType(Types.CLOB, "longtext");
    //      registerColumnType( Types.CLOB, 16777215, "mediumtext" );
    //      registerColumnType( Types.CLOB, 65535, "text" );
    registerVarcharTypes();

    registerFunction("ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER));
    registerFunction("bin", new StandardSQLFunction("bin", StandardBasicTypes.STRING));
    registerFunction("char_length", new StandardSQLFunction("char_length", StandardBasicTypes.LONG));
    registerFunction("character_length", new StandardSQLFunction("character_length", StandardBasicTypes.LONG));
    registerFunction("lcase", new StandardSQLFunction("lcase"));
    registerFunction("lower", new StandardSQLFunction("lower"));
    registerFunction("ltrim", new StandardSQLFunction("ltrim"));
    registerFunction("ord", new StandardSQLFunction("ord", StandardBasicTypes.INTEGER));
    registerFunction("quote", new StandardSQLFunction("quote"));
    registerFunction("reverse", new StandardSQLFunction("reverse"));
    registerFunction("rtrim", new StandardSQLFunction("rtrim"));
    registerFunction("soundex", new StandardSQLFunction("soundex"));
    registerFunction("space", new StandardSQLFunction("space", StandardBasicTypes.STRING));
    registerFunction("ucase", new StandardSQLFunction("ucase"));
    registerFunction("upper", new StandardSQLFunction("upper"));
    registerFunction("unhex", new StandardSQLFunction("unhex", StandardBasicTypes.STRING));

    registerFunction("abs", new StandardSQLFunction("abs"));
    registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER));

    registerFunction("acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE));
    registerFunction("asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE));
    registerFunction("atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE));
    registerFunction("cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE));
    registerFunction("cot", new StandardSQLFunction("cot", StandardBasicTypes.DOUBLE));
    registerFunction("crc32", new StandardSQLFunction("crc32", StandardBasicTypes.LONG));
    registerFunction("exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE));
    registerFunction("ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE));
    registerFunction("log", new StandardSQLFunction("log", StandardBasicTypes.DOUBLE));
    registerFunction("log2", new StandardSQLFunction("log2", StandardBasicTypes.DOUBLE));
    registerFunction("log10", new StandardSQLFunction("log10", StandardBasicTypes.DOUBLE));
    registerFunction("pi", new NoArgSQLFunction("pi", StandardBasicTypes.DOUBLE));
    registerFunction("rand", new NoArgSQLFunction("rand", StandardBasicTypes.DOUBLE));
    registerFunction("sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE));
    registerFunction("sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE));
    registerFunction("tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE));

    registerFunction("radians", new StandardSQLFunction("radians", StandardBasicTypes.DOUBLE));
    registerFunction("degrees", new StandardSQLFunction("degrees", StandardBasicTypes.DOUBLE));

    registerFunction("ceiling", new StandardSQLFunction("ceiling", StandardBasicTypes.INTEGER));
    registerFunction("ceil", new StandardSQLFunction("ceil", StandardBasicTypes.INTEGER));
    registerFunction("floor", new StandardSQLFunction("floor", StandardBasicTypes.INTEGER));
    registerFunction("round", new StandardSQLFunction("round"));

    registerFunction("datediff", new StandardSQLFunction("datediff", StandardBasicTypes.INTEGER));
    registerFunction("timediff", new StandardSQLFunction("timediff", StandardBasicTypes.TIME));
    registerFunction("date_format", new StandardSQLFunction("date_format", StandardBasicTypes.STRING));

    registerFunction("curdate", new NoArgSQLFunction("curdate", StandardBasicTypes.DATE));
    registerFunction("curtime", new NoArgSQLFunction("curtime", StandardBasicTypes.TIME));
    registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false));
    registerFunction("current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false));
    registerFunction("current_timestamp",
            new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("date", new StandardSQLFunction("date", StandardBasicTypes.DATE));
    registerFunction("day", new StandardSQLFunction("day", StandardBasicTypes.INTEGER));
    registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", StandardBasicTypes.INTEGER));
    registerFunction("dayname", new StandardSQLFunction("dayname", StandardBasicTypes.STRING));
    registerFunction("dayofweek", new StandardSQLFunction("dayofweek", StandardBasicTypes.INTEGER));
    registerFunction("dayofyear", new StandardSQLFunction("dayofyear", StandardBasicTypes.INTEGER));
    registerFunction("from_days", new StandardSQLFunction("from_days", StandardBasicTypes.DATE));
    registerFunction("from_unixtime", new StandardSQLFunction("from_unixtime", StandardBasicTypes.TIMESTAMP));
    registerFunction("hour", new StandardSQLFunction("hour", StandardBasicTypes.INTEGER));
    registerFunction("last_day", new StandardSQLFunction("last_day", StandardBasicTypes.DATE));
    registerFunction("localtime", new NoArgSQLFunction("localtime", StandardBasicTypes.TIMESTAMP));
    registerFunction("localtimestamp", new NoArgSQLFunction("localtimestamp", StandardBasicTypes.TIMESTAMP));
    registerFunction("microseconds", new StandardSQLFunction("microseconds", StandardBasicTypes.INTEGER));
    registerFunction("minute", new StandardSQLFunction("minute", StandardBasicTypes.INTEGER));
    registerFunction("month", new StandardSQLFunction("month", StandardBasicTypes.INTEGER));
    registerFunction("monthname", new StandardSQLFunction("monthname", StandardBasicTypes.STRING));
    registerFunction("now", new NoArgSQLFunction("now", StandardBasicTypes.TIMESTAMP));
    registerFunction("quarter", new StandardSQLFunction("quarter", StandardBasicTypes.INTEGER));
    registerFunction("second", new StandardSQLFunction("second", StandardBasicTypes.INTEGER));
    registerFunction("sec_to_time", new StandardSQLFunction("sec_to_time", StandardBasicTypes.TIME));
    registerFunction("sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.TIMESTAMP));
    registerFunction("time", new StandardSQLFunction("time", StandardBasicTypes.TIME));
    registerFunction("timestamp", new StandardSQLFunction("timestamp", StandardBasicTypes.TIMESTAMP));
    registerFunction("time_to_sec", new StandardSQLFunction("time_to_sec", StandardBasicTypes.INTEGER));
    registerFunction("to_days", new StandardSQLFunction("to_days", StandardBasicTypes.LONG));
    registerFunction("unix_timestamp", new StandardSQLFunction("unix_timestamp", StandardBasicTypes.LONG));
    registerFunction("utc_date", new NoArgSQLFunction("utc_date", StandardBasicTypes.STRING));
    registerFunction("utc_time", new NoArgSQLFunction("utc_time", StandardBasicTypes.STRING));
    registerFunction("utc_timestamp", new NoArgSQLFunction("utc_timestamp", StandardBasicTypes.STRING));
    registerFunction("week", new StandardSQLFunction("week", StandardBasicTypes.INTEGER));
    registerFunction("weekday", new StandardSQLFunction("weekday", StandardBasicTypes.INTEGER));
    registerFunction("weekofyear", new StandardSQLFunction("weekofyear", StandardBasicTypes.INTEGER));
    registerFunction("year", new StandardSQLFunction("year", StandardBasicTypes.INTEGER));
    registerFunction("yearweek", new StandardSQLFunction("yearweek", StandardBasicTypes.INTEGER));

    registerFunction("hex", new StandardSQLFunction("hex", StandardBasicTypes.STRING));
    registerFunction("oct", new StandardSQLFunction("oct", StandardBasicTypes.STRING));

    registerFunction("octet_length", new StandardSQLFunction("octet_length", StandardBasicTypes.LONG));
    registerFunction("bit_length", new StandardSQLFunction("bit_length", StandardBasicTypes.LONG));

    registerFunction("bit_count", new StandardSQLFunction("bit_count", StandardBasicTypes.LONG));
    registerFunction("encrypt", new StandardSQLFunction("encrypt", StandardBasicTypes.STRING));
    registerFunction("md5", new StandardSQLFunction("md5", StandardBasicTypes.STRING));
    registerFunction("sha1", new StandardSQLFunction("sha1", StandardBasicTypes.STRING));
    registerFunction("sha", new StandardSQLFunction("sha", StandardBasicTypes.STRING));

    registerFunction("concat", new StandardSQLFunction("concat", StandardBasicTypes.STRING));

    getDefaultProperties().setProperty(Environment.MAX_FETCH_DEPTH, "2");
    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
}

From source file:com.syndiceo.PostgreSQLDialect.java

License:Open Source License

public PostgreSQLDialect() {
    super();/* w ww  . j  av  a2s  .c  om*/
    registerColumnType(Types.BIT, "bool");
    registerColumnType(Types.BIGINT, "int8");
    registerColumnType(Types.SMALLINT, "int2");
    registerColumnType(Types.TINYINT, "int2");
    registerColumnType(Types.INTEGER, "int4");
    registerColumnType(Types.CHAR, "char(1)");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.FLOAT, "float4");
    registerColumnType(Types.DOUBLE, "float8");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.VARBINARY, "bytea");
    registerColumnType(Types.BINARY, "bytea");
    registerColumnType(Types.LONGVARCHAR, "text");
    registerColumnType(Types.LONGVARBINARY, "bytea");
    registerColumnType(Types.CLOB, "text");
    registerColumnType(Types.BLOB, "oid");
    registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.OTHER, "uuid");

    registerFunction("abs", new StandardSQLFunction("abs"));
    registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER));

    registerFunction("acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE));
    registerFunction("asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE));
    registerFunction("atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE));
    registerFunction("cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE));
    registerFunction("cot", new StandardSQLFunction("cot", StandardBasicTypes.DOUBLE));
    registerFunction("exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE));
    registerFunction("ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE));
    registerFunction("log", new StandardSQLFunction("log", StandardBasicTypes.DOUBLE));
    registerFunction("sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE));
    registerFunction("sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE));
    registerFunction("cbrt", new StandardSQLFunction("cbrt", StandardBasicTypes.DOUBLE));
    registerFunction("tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE));
    registerFunction("radians", new StandardSQLFunction("radians", StandardBasicTypes.DOUBLE));
    registerFunction("degrees", new StandardSQLFunction("degrees", StandardBasicTypes.DOUBLE));

    registerFunction("stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE));
    registerFunction("variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE));

    registerFunction("random", new NoArgSQLFunction("random", StandardBasicTypes.DOUBLE));

    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("trunc", new StandardSQLFunction("trunc"));
    registerFunction("ceil", new StandardSQLFunction("ceil"));
    registerFunction("floor", new StandardSQLFunction("floor"));

    registerFunction("chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER));
    registerFunction("lower", new StandardSQLFunction("lower"));
    registerFunction("upper", new StandardSQLFunction("upper"));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("initcap", new StandardSQLFunction("initcap"));
    registerFunction("to_ascii", new StandardSQLFunction("to_ascii"));
    registerFunction("quote_ident", new StandardSQLFunction("quote_ident", StandardBasicTypes.STRING));
    registerFunction("quote_literal", new StandardSQLFunction("quote_literal", StandardBasicTypes.STRING));
    registerFunction("md5", new StandardSQLFunction("md5"));
    registerFunction("ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER));
    registerFunction("char_length", new StandardSQLFunction("char_length", StandardBasicTypes.LONG));
    registerFunction("bit_length", new StandardSQLFunction("bit_length", StandardBasicTypes.LONG));
    registerFunction("octet_length", new StandardSQLFunction("octet_length", StandardBasicTypes.LONG));

    registerFunction("age", new StandardSQLFunction("age"));
    registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false));
    registerFunction("current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false));
    registerFunction("current_timestamp",
            new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("date_trunc", new StandardSQLFunction("date_trunc", StandardBasicTypes.TIMESTAMP));
    registerFunction("localtime", new NoArgSQLFunction("localtime", StandardBasicTypes.TIME, false));
    registerFunction("localtimestamp",
            new NoArgSQLFunction("localtimestamp", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("now", new NoArgSQLFunction("now", StandardBasicTypes.TIMESTAMP));
    registerFunction("timeofday", new NoArgSQLFunction("timeofday", StandardBasicTypes.STRING));

    registerFunction("current_user", new NoArgSQLFunction("current_user", StandardBasicTypes.STRING, false));
    registerFunction("session_user", new NoArgSQLFunction("session_user", StandardBasicTypes.STRING, false));
    registerFunction("user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false));
    registerFunction("current_database",
            new NoArgSQLFunction("current_database", StandardBasicTypes.STRING, true));
    registerFunction("current_schema", new NoArgSQLFunction("current_schema", StandardBasicTypes.STRING, true));

    registerFunction("to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING));
    registerFunction("to_date", new StandardSQLFunction("to_date", StandardBasicTypes.DATE));
    registerFunction("to_timestamp", new StandardSQLFunction("to_timestamp", StandardBasicTypes.TIMESTAMP));
    registerFunction("to_number", new StandardSQLFunction("to_number", StandardBasicTypes.BIG_DECIMAL));

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "(", "||", ")"));

    registerFunction("locate", new PositionSubstringFunction());

    registerFunction("str", new SQLFunctionTemplate(StandardBasicTypes.STRING, "cast(?1 as varchar)"));

    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
    getDefaultProperties().setProperty(Environment.NON_CONTEXTUAL_LOB_CREATION, "true");
}

From source file:de.fhdo.terminologie.ws.search.ListValueSetContents.java

License:Apache License

public ListValueSetContentsResponseType ListValueSetContents(ListValueSetContentsRequestType parameter,
        org.hibernate.Session session, String ipAddress) {
    if (logger.isInfoEnabled())
        logger.info("====== ListValueSetContents gestartet ======");

    // Return-Informationen anlegen
    ListValueSetContentsResponseType response = new ListValueSetContentsResponseType();
    response.setReturnInfos(new ReturnType());

    // Parameter prfen
    if (validateParameter(parameter, response) == false) {
        return response; // Fehler bei den Parametern
    }/*from  ww  w .  ja v a2 s  . c  o m*/

    boolean createHibernateSession = (session == null);

    // Login-Informationen auswerten (gilt fr jeden Webservice)
    boolean loggedIn = false;
    AuthenticateInfos loginInfoType = null;
    if (parameter != null && parameter.getLoginToken() != null) {
        loginInfoType = Authorization.authenticate(ipAddress, parameter.getLoginToken());
        loggedIn = loginInfoType != null;
    }

    try {
        // Hibernate-Block, Session ffnen
        org.hibernate.Session hb_session = null;

        if (createHibernateSession) {
            hb_session = HibernateUtil.getSessionFactory().openSession();
        } else {
            hb_session = session;
        }

        //hb_session.getTransaction().begin();
        //List<CodeSystemEntity> entityList = null;//new LinkedList<CodeSystemEntity>();
        try {
            ValueSetVersion vsv = parameter.getValueSet().getValueSetVersions().iterator().next();
            long valueSetVersionId = vsv.getVersionId();

            logger.debug("valueSetVersionId: " + valueSetVersionId);

            // Zuerst passenden Level-Metadataparameter lesen
            long metadataParameter_Level_Id = 0; // 355

            if (parameter.getReadMetadataLevel() != null && parameter.getReadMetadataLevel().booleanValue()) {
                logger.debug("Finde Level...");
                String hql = "select distinct mp from MetadataParameter mp join mp.valueSet vs join vs.valueSetVersions vsv where vsv.versionId="
                        + valueSetVersionId + " and mp.paramName='Level'";
                List list = hb_session.createQuery(hql).list();

                if (list != null && list.size() > 0) {
                    MetadataParameter mp = (MetadataParameter) list.get(0);
                    metadataParameter_Level_Id = mp.getId();
                }
            }

            logger.debug("metadataParameter_Level_Id: " + metadataParameter_Level_Id);

            String sql = "select * from code_system_entity_version csev"
                    + " JOIN concept_value_set_membership cvsm ON csev.versionId=cvsm.codeSystemEntityVersionId"
                    + " JOIN code_system_concept csc ON csev.versionId=csc.codeSystemEntityVersionId"
                    + " JOIN code_system_entity cse ON csev.codeSystemEntityId=cse.id"
                    + " JOIN code_system_version_entity_membership csvem ON csvem.codeSystemEntityId=cse.id"
                    + " JOIN code_system_version csv ON csv.versionId=csvem.codeSystemVersionId";

            if (metadataParameter_Level_Id > 0)
                sql += " LEFT JOIN value_set_metadata_value vsmv ON csev.versionId=vsmv.codeSystemEntityVersionId";

            boolean virtualValueSet = false;

            ValueSetVersion vsv_db = (ValueSetVersion) hb_session.get(ValueSetVersion.class,
                    vsv.getVersionId());
            if (vsv_db == null) {
                response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.WARN);
                response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
                response.getReturnInfos()
                        .setMessage("Value Set with id " + vsv.getVersionId() + " does not exist.");
                return response;
            }
            if (vsv_db.getVirtualCodeSystemVersionId() != null && vsv_db.getVirtualCodeSystemVersionId() > 0) {
                // get concepts from a codesystem version
                sql = "select * from code_system_entity_version csev"
                        + " JOIN code_system_concept csc ON csev.versionId=csc.codeSystemEntityVersionId"
                        + " JOIN code_system_entity cse ON csev.codeSystemEntityId=cse.id"
                        + " JOIN code_system_version_entity_membership csvem ON csvem.codeSystemEntityId=cse.id"
                        + " JOIN code_system_version csv ON csv.versionId=csvem.codeSystemVersionId";

                virtualValueSet = true;
            }

            // Parameter dem Helper hinzufgen
            // bitte immer den Helper verwenden oder manuell Parameter per Query.setString() hinzufgen,
            // sonst sind SQL-Injections mglich
            HQLParameterHelper parameterHelper = new HQLParameterHelper();
            if (virtualValueSet == false) {
                parameterHelper.addParameter("", "cvsm.valuesetVersionId", valueSetVersionId);
            }

            if (metadataParameter_Level_Id > 0)
                parameterHelper.addParameter("", "vsmv.metadataParameterId", metadataParameter_Level_Id);

            if (loggedIn == false) {
                parameterHelper.addParameter("csev.", "statusVisibility",
                        Definitions.STATUS_CODES.ACTIVE.getCode());
            }

            if (virtualValueSet == false && vsv.getConceptValueSetMemberships() != null
                    && vsv.getConceptValueSetMemberships().size() > 0) {
                ConceptValueSetMembership cvsm = vsv.getConceptValueSetMemberships().iterator().next();
                if (cvsm.getStatusDate() != null)
                    parameterHelper.addParameter("cvsm.", "statusDate", cvsm.getStatusDate());
            }

            if (virtualValueSet) {
                parameterHelper.addParameter("csv.", "versionId", vsv_db.getVirtualCodeSystemVersionId());
            }

            if (parameter.getCodeSystemEntity() != null
                    && parameter.getCodeSystemEntity().getCodeSystemEntityVersions() != null
                    && parameter.getCodeSystemEntity().getCodeSystemEntityVersions().size() > 0) {
                CodeSystemEntityVersion csev = (CodeSystemEntityVersion) parameter.getCodeSystemEntity()
                        .getCodeSystemEntityVersions().toArray()[0];
                parameterHelper.addParameter("csev.", "statusVisibilityDate", csev.getStatusVisibilityDate());

                if (csev.getCodeSystemConcepts() != null && csev.getCodeSystemConcepts().size() > 0) {
                    CodeSystemConcept csc = (CodeSystemConcept) csev.getCodeSystemConcepts().toArray()[0];
                    parameterHelper.addParameter("csc.", "code", csc.getCode());
                    parameterHelper.addParameter("csc.", "term", csc.getTerm());
                    parameterHelper.addParameter("csc.", "termAbbrevation", csc.getTermAbbrevation());
                    parameterHelper.addParameter("csc.", "isPreferred", csc.getIsPreferred());

                    /*if (csc.getCodeSystemConceptTranslations() != null && csc.getCodeSystemConceptTranslations().size() > 0)
                    {
                      CodeSystemConceptTranslation csct = (CodeSystemConceptTranslation) csc.getCodeSystemConceptTranslations().toArray()[0];
                      parameterHelper.addParameter("csct.", "term", csct.getTerm());
                      parameterHelper.addParameter("csct.", "termAbbrevation", csct.getTermAbbrevation());
                      if (csct.getLanguageCd() != null && csct.getLanguageCd().length() > 0)
                      {
                        languageCd = csct.getLanguageCd();
                      }
                    }*/
                }
            }

            // Parameter hinzufgen (immer mit AND verbunden)
            // Gesamt-Anzahl lesen
            String where = parameterHelper.getWhere("");

            String sortStr = " ORDER BY cvsm.orderNr,csc.code";

            if (virtualValueSet)
                sortStr = " ORDER BY csc.code";

            if (parameter.getSortingParameter() != null) {
                if (parameter.getSortingParameter().getSortType() == null || parameter.getSortingParameter()
                        .getSortType() == SortingType.SortType.ALPHABETICALLY) {
                    sortStr = " ORDER BY";

                    if (parameter.getSortingParameter().getSortBy() != null
                            && parameter.getSortingParameter().getSortBy() == SortingType.SortByField.TERM) {
                        sortStr += " csc.term";
                    } else {
                        sortStr += " csc.code";
                    }

                    if (parameter.getSortingParameter().getSortDirection() != null && parameter
                            .getSortingParameter().getSortDirection() == SortingType.SortDirection.DESCENDING) {
                        sortStr += " desc";
                    }
                }
            }

            String where_all = where + sortStr;
            sql += " " + where_all;

            logger.debug("SQL: " + sql);

            // Query erstellen
            SQLQuery q = hb_session.createSQLQuery(sql);
            q.addScalar("csc.code", StandardBasicTypes.TEXT); // Index: 0
            q.addScalar("csc.term", StandardBasicTypes.TEXT);
            q.addScalar("csc.termAbbrevation", StandardBasicTypes.TEXT);
            q.addScalar("csc.description", StandardBasicTypes.TEXT);
            q.addScalar("csc.isPreferred", StandardBasicTypes.BOOLEAN);
            q.addScalar("csc.codeSystemEntityVersionId", StandardBasicTypes.LONG);

            q.addScalar("csev.effectiveDate", StandardBasicTypes.DATE); // Index: 6
            q.addScalar("csev.insertTimestamp", StandardBasicTypes.DATE);
            q.addScalar("csev.isLeaf", StandardBasicTypes.BOOLEAN);
            q.addScalar("csev.majorRevision", StandardBasicTypes.INTEGER);
            q.addScalar("csev.minorRevision", StandardBasicTypes.INTEGER);
            q.addScalar("csev.statusVisibility", StandardBasicTypes.INTEGER);
            q.addScalar("csev.statusVisibilityDate", StandardBasicTypes.DATE);
            q.addScalar("csev.versionId", StandardBasicTypes.LONG);
            q.addScalar("csev.codeSystemEntityId", StandardBasicTypes.LONG);

            q.addScalar("cse.id", StandardBasicTypes.LONG); // Index: 15
            q.addScalar("cse.currentVersionId", StandardBasicTypes.LONG);

            q.addScalar("csc.meaning", StandardBasicTypes.TEXT); //Index: 17
            q.addScalar("csc.hints", StandardBasicTypes.TEXT);

            if (virtualValueSet == false) {
                q.addScalar("cvsm.valueOverride", StandardBasicTypes.TEXT); //Index: 19
                q.addScalar("cvsm.status", StandardBasicTypes.INTEGER);
                q.addScalar("cvsm.statusDate", StandardBasicTypes.DATE);
                q.addScalar("cvsm.isStructureEntry", StandardBasicTypes.BOOLEAN);
                q.addScalar("cvsm.orderNr", StandardBasicTypes.LONG);
                q.addScalar("cvsm.description", StandardBasicTypes.TEXT);
                q.addScalar("cvsm.hints", StandardBasicTypes.TEXT);
            }

            q.addScalar("csvem.isAxis", StandardBasicTypes.BOOLEAN); // Index: 26
            q.addScalar("csvem.isMainClass", StandardBasicTypes.BOOLEAN);

            q.addScalar("csv.previousVersionID", StandardBasicTypes.LONG); // Index: 28
            q.addScalar("csv.name", StandardBasicTypes.TEXT);
            q.addScalar("csv.status", StandardBasicTypes.INTEGER);
            q.addScalar("csv.statusDate", StandardBasicTypes.DATE);
            q.addScalar("csv.releaseDate", StandardBasicTypes.DATE);
            q.addScalar("csv.expirationDate", StandardBasicTypes.DATE);
            q.addScalar("csv.source", StandardBasicTypes.TEXT);
            q.addScalar("csv.preferredLanguageCd", StandardBasicTypes.TEXT);
            q.addScalar("csv.oid", StandardBasicTypes.TEXT);
            q.addScalar("csv.licenceHolder", StandardBasicTypes.TEXT);
            q.addScalar("csv.underLicence", StandardBasicTypes.BOOLEAN);
            q.addScalar("csv.insertTimestamp", StandardBasicTypes.DATE);
            q.addScalar("csv.validityRange", StandardBasicTypes.LONG); // Index: 40

            q.addScalar("csv.versionId", StandardBasicTypes.LONG);

            if (metadataParameter_Level_Id > 0) {
                q.addScalar("vsmv.parameterValue", StandardBasicTypes.TEXT); // Index: 42
            }

            // TODO bersetzungen
            /*q.addScalar("translation_term", StandardBasicTypes.TEXT);  // Index: 17
             q.addScalar("translation_termAbbrevation", StandardBasicTypes.TEXT);
             q.addScalar("translation_languageId", StandardBasicTypes.LONG);
             q.addScalar("translation_description", StandardBasicTypes.TEXT);
             q.addScalar("translation_id", StandardBasicTypes.LONG);
                    
             */
            parameterHelper.applySQLParameter(q);
            //q.setLong("languageId", languageId);

            //+ " ORDER BY csc.code"
            //q.setParameter("codeSystemVersionId", codeSystemVersionId);

            /*List<CodeSystemConcept> conceptList = (List<CodeSystemConcept>) q.list();
                    
             for (CodeSystemConcept csc : conceptList)
             {
             logger.debug(csc.getCode());
             anzahl++;
             }*/
            response.setCodeSystemEntity(new LinkedList<CodeSystemEntity>());

            List conceptList = (List) q.list();

            logger.debug("Anzahl: " + conceptList.size());

            long lastCodeSystemEntityVersionId = 0;
            CodeSystemEntity cse;
            CodeSystemEntityVersion csev;
            CodeSystemConcept csc;
            CodeSystemVersionEntityMembership csvem;
            CodeSystemVersion csv;
            ConceptValueSetMembership cvsm;
            boolean fertig = false;
            int anzahl = 0;

            Iterator it = conceptList.iterator();

            while (it.hasNext()) {
                Object[] item = null;
                long codeSystemEntityVersionId = 0;
                do {
                    if (it.hasNext() == false) {
                        fertig = true;
                        break;
                    }

                    item = (Object[]) it.next();

                    // Prfen, ob Translation (1:N)
                    codeSystemEntityVersionId = (Long) item[5];
                    /*if (lastCodeSystemEntityVersionId == codeSystemEntityVersionId)
                     {
                     // Gleiches Konzept, Assoziation hinzufgen
                     // TODO Sprachen hinzufgen ?
                     //if (parameter.isLookForward())
                     //  addAssociationToEntityVersion(csev, item);
                     }*/
                } while (lastCodeSystemEntityVersionId == codeSystemEntityVersionId);

                if (fertig)
                    break;

                // Konzepte zusammenbauen
                cse = new CodeSystemEntity();
                csev = new CodeSystemEntityVersion();
                csc = new CodeSystemConcept();
                csvem = new CodeSystemVersionEntityMembership();
                csvem.setCodeSystemVersion(new CodeSystemVersion());
                cvsm = new ConceptValueSetMembership();
                csv = new CodeSystemVersion();

                int index = 0;

                // Konzept
                /*if (item[0] != null)
                 csc.setCode(item[0].toString());
                 if (item[1] != null)
                 csc.setTerm(item[1].toString());
                 if (item[2] != null)
                 csc.setTermAbbrevation(item[2].toString());
                 if (item[3] != null)
                 csc.setDescription(item[3].toString());
                 if (item[4] != null)
                 csc.setIsPreferred((Boolean) item[4]);
                 if (item[5] != null)
                 csc.setCodeSystemEntityVersionId((Long) item[5]);
                 if (item[17] != null)
                 csc.setMeaning(item[17].toString());
                 if (item[18] != null)
                 csc.setHints(item[18].toString());
                        
                 // Entity Version
                 if (item[6] != null)
                 csev.setEffectiveDate((Date) item[6]);
                 if (item[7] != null)
                 csev.setInsertTimestamp((Date) item[7]);
                 if (item[8] != null)
                 csev.setIsLeaf((Boolean) item[8]);
                 if (item[9] != null)
                 csev.setMajorRevision((Integer) item[9]);
                 if (item[10] != null)
                 csev.setMinorRevision((Integer) item[10]);
                 if (item[11] != null)
                 csev.setStatusVisibility((Integer) item[11]);
                 if (item[12] != null)
                 csev.setStatusVisibilityDate((Date) item[12]);
                 if (item[13] != null)
                 {
                 csev.setVersionId((Long) item[13]);
                 cvsm.setId(new ConceptValueSetMembershipId(csev.getVersionId(), valueSetVersionId));
                 }
                 // Code System Entity
                 if (item[15] != null)
                 cse.setId((Long) item[15]);
                 if (item[16] != null)
                 cse.setCurrentVersionId((Long) item[16]);
                        
                 if (virtualValueSet == false)
                 {
                 if (item[19] != null)
                 cvsm.setValueOverride(item[19].toString());
                 if (item[20] != null)
                 cvsm.setStatus((Integer) item[20]);
                 if (item[21] != null)
                 cvsm.setStatusDate((Date) item[21]);
                 if (item[22] != null)
                 cvsm.setIsStructureEntry((Boolean) item[22]);
                 if (item[23] != null)
                 cvsm.setOrderNr((Long) item[23]);
                 if (item[24] != null)
                 cvsm.setDescription(item[24].toString());
                 if (item[25] != null)
                 cvsm.setHints(item[25].toString());
                 }
                        
                 if (item[26] != null)
                 csvem.setIsAxis((Boolean) item[26]);
                 if (item[27] != null)
                 csvem.setIsMainClass((Boolean) item[27]);
                        
                 if (item[28] != null)
                 csv.setPreviousVersionId((Long) item[28]);
                 if (item[29] != null)
                 csv.setName(item[29].toString());
                 if (item[30] != null)
                 csv.setStatus((Integer) item[30]);
                 if (item[31] != null)
                 csv.setStatusDate((Date) item[31]);
                 if (item[32] != null)
                 csv.setReleaseDate((Date) item[32]);
                 if (item[33] != null)
                 csv.setExpirationDate((Date) item[33]);
                 if (item[34] != null)
                 csv.setSource(item[34].toString());
                 if (item[35] != null)
                 csv.setPreferredLanguageCd(item[35].toString());
                 if (item[36] != null)
                 csv.setOid(item[36].toString());
                 if (item[37] != null)
                 csv.setLicenceHolder(item[37].toString());
                 if (item[38] != null)
                 csv.setUnderLicence((Boolean) item[38]);
                 if (item[39] != null)
                 csv.setInsertTimestamp((Date) item[39]);
                 if (item[40] != null)
                 csv.setValidityRange((Long) item[40]);
                        
                 // Metadaten hinzufgen
                 if (item[41] != null)
                 csv.setVersionId((Long) item[41]);*/
                csc.setCode(getItemStr(item, index++));
                csc.setTerm(getItemStr(item, index++));
                csc.setTermAbbrevation(getItemStr(item, index++));
                csc.setDescription(getItemStr(item, index++));
                csc.setIsPreferred(getItemBool(item, index++));
                csc.setCodeSystemEntityVersionId(getItemLong(item, index++));

                csev.setEffectiveDate(getItemDate(item, index++));
                csev.setInsertTimestamp(getItemDate(item, index++));
                csev.setIsLeaf(getItemBool(item, index++));
                csev.setMajorRevision(getItemInt(item, index++));
                csev.setMinorRevision(getItemInt(item, index++));
                csev.setStatusVisibility(getItemInt(item, index++));
                csev.setStatusVisibilityDate(getItemDate(item, index++));
                csev.setVersionId(getItemLong(item, index++));
                if (csev.getVersionId() != null)
                    cvsm.setId(new ConceptValueSetMembershipId(csev.getVersionId(), valueSetVersionId));

                long cse_id = getItemLong(item, index++);

                // Code System Entity
                cse.setId(getItemLong(item, index++));
                cse.setCurrentVersionId(getItemLong(item, index++));

                csc.setMeaning(getItemStr(item, index++)); // Index: 17
                csc.setHints(getItemStr(item, index++));

                if (virtualValueSet == false) {
                    cvsm.setValueOverride(getItemStr(item, index++));
                    cvsm.setStatus(getItemInt(item, index++));
                    cvsm.setStatusDate(getItemDate(item, index++));
                    cvsm.setIsStructureEntry(getItemBool(item, index++));
                    cvsm.setOrderNr(getItemLong(item, index++));
                    cvsm.setDescription(getItemStr(item, index++));
                    cvsm.setHints(getItemStr(item, index++));
                }

                csvem.setIsAxis(getItemBool(item, index++));
                csvem.setIsMainClass(getItemBool(item, index++));

                csv.setPreviousVersionId(getItemLong(item, index++));
                csv.setName(getItemStr(item, index++));
                csv.setStatus(getItemInt(item, index++));
                csv.setStatusDate(getItemDate(item, index++));
                csv.setReleaseDate(getItemDate(item, index++));
                csv.setExpirationDate(getItemDate(item, index++));
                csv.setSource(getItemStr(item, index++));
                csv.setPreferredLanguageCd(getItemStr(item, index++));
                csv.setOid(getItemStr(item, index++));
                csv.setLicenceHolder(getItemStr(item, index++));
                csv.setUnderLicence(getItemBool(item, index++));
                csv.setInsertTimestamp(getItemDate(item, index++));
                csv.setValidityRange(getItemLong(item, index++));

                // Metadaten hinzufgen
                if (metadataParameter_Level_Id > 0)
                    csv.setVersionId(getItemLong(item, index++));

                // Metadaten hinzufgen
                if (item != null && item.length > 42 && item[42] != null) {
                    ValueSetMetadataValue mv = new ValueSetMetadataValue();
                    mv.setParameterValue(item[42].toString());
                    mv.setCodeSystemEntityVersion(null);
                    mv.setMetadataParameter(null);
                    csev.setValueSetMetadataValues(new HashSet<ValueSetMetadataValue>());
                    csev.getValueSetMetadataValues().add(mv);
                }

                // TODO Sprachen hinzufgen
                csvem.setCodeSystemVersion(csv);
                csev.setCodeSystemConcepts(new HashSet<CodeSystemConcept>());
                csev.getCodeSystemConcepts().add(csc);
                csev.setConceptValueSetMemberships(new HashSet<ConceptValueSetMembership>());
                csev.getConceptValueSetMemberships().add(cvsm);
                cse.setCodeSystemEntityVersions(new HashSet<CodeSystemEntityVersion>());
                cse.getCodeSystemEntityVersions().add(csev);
                cse.setCodeSystemVersionEntityMemberships(new HashSet<CodeSystemVersionEntityMembership>());
                cse.getCodeSystemVersionEntityMemberships().add(csvem);
                response.getCodeSystemEntity().add(cse);

                lastCodeSystemEntityVersionId = codeSystemEntityVersionId;

                anzahl++;
            }

            response.getReturnInfos().setCount(anzahl);

            if (response.getCodeSystemEntity() == null || anzahl == 0) {
                //response.getReturnInfos().setMessage("Zu dem angegebenen ValueSet wurden keine Konzepte gefunden!");
                response.getReturnInfos().setMessage("No concepts found for given Value Set!");
                response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
            } else {
                if (virtualValueSet)
                    response.getReturnInfos()
                            .setMessage(anzahl + " concepts successfully returned (Virtual Value Set).");
                else
                    response.getReturnInfos().setMessage(anzahl + " concepts successfully returned.");
                response.getReturnInfos().setStatus(ReturnType.Status.OK);
            }
            response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.INFO);
        } catch (Exception e) {

            //hb_session.getTransaction().rollback();
            // Fehlermeldung an den Aufrufer weiterleiten
            response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.ERROR);
            response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
            response.getReturnInfos()
                    .setMessage("Fehler bei 'ListValueSetContents', Hibernate: " + e.getLocalizedMessage());

            logger.error("Fehler in 'ListValueSetContents', Hibernate: " + e.getLocalizedMessage());
            LoggingOutput.outputException(e, this);
        } finally {
            if (createHibernateSession)
                hb_session.close();
        }
    } catch (Exception e) {
        // Fehlermeldung an den Aufrufer weiterleiten
        response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.ERROR);
        response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
        response.getReturnInfos().setMessage("Fehler bei 'ReturnConceptDetails': " + e.getLocalizedMessage());

        logger.error("Fehler bei 'ListValueSetContents': " + e.getLocalizedMessage());
        LoggingOutput.outputException(e, this);
    }

    return response;
}

From source file:dk.teachus.backend.dao.hibernate.PersistentDateMidnight.java

License:Apache License

public Object nullSafeGet(ResultSet resultSet, String string) throws SQLException {
    Object date = StandardBasicTypes.DATE.nullSafeGet(resultSet, string);
    if (date == null) {
        return null;
    }/*from  w  w w . j av  a 2 s  . com*/

    return new DateMidnight(date);
}

From source file:dk.teachus.backend.dao.hibernate.PersistentDateMidnight.java

License:Apache License

public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index)
        throws HibernateException, SQLException {
    if (value == null) {
        StandardBasicTypes.DATE.nullSafeSet(preparedStatement, null, index);
    } else {//from w ww .j  a v a 2  s  .  c  o  m
        StandardBasicTypes.DATE.nullSafeSet(preparedStatement, ((DateMidnight) value).toDate(), index);
    }
}