Skip to content

Instantly share code, notes, and snippets.

package example.spring.staticinjection;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan( basePackageClasses = { UnitOfWorks.class } )
public class StaticInjectionConfig {
<!-- UnitOfWorkFactory 인스턴스를 UnitOfWorks Singleton의 static field에 설정합니다. -->
<bean name="unitOfWorkInitializer" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="kr.nsoft.data.hibernate.unitofwork.UnitOfWorks.setUnitOfWorkFactory"/>
<property name="arguments">
<list>
<ref bean="unitOfWorkFactory"/>
</list>
</property>
</bean>
package example.spring.staticinjection;
public class UnitOfWorks {
private static UnitOfWorkFactory unitOfWorkFactory;
public static void setUnitOfWorkFactory(UnitOfWorkFactory factory) {
unitOfWorkFactory = factory;
}
package example.spring.staticinjection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class UnitOfWorks {
private static UnitOfWorkFactory unitOfWorkFactory;
/** 지정한 값이 두 속성 값 사이에 존재하는지 여부 */
public static Criterion getIsInRangeCriterion(final String loPropertyName,
final String hiPropertyName,
Object value,
boolean includeLo,
boolean includeHi) {
Guard.shouldNotBeNull(value, "value");
Criterion loCriteria = (includeLo) ? le(loPropertyName, value)
: lt(loPropertyName, value);
public static Criterion getIsBetweenCriterion(String propertyName, Object lo, Object hi,
boolean includeLo, boolean includeHi) {
shouldNotBeEmpty(propertyName, "propertyName");
if (lo == null && hi == null)
throw new IllegalArgumentException("상하한 값 모두 null 이면 안됩니다.");
if (lo != null && hi != null && includeLo && includeHi)
return between(propertyName, lo, hi);
@debop
debop / CriteriaTool.java
Created May 2, 2013 15:02
Overlap Criteria
/** 지정한 범위 값이 두 속성 값 구간과 겹치는지를 알아보기 위한 질의어 */
public static Criterion getIsOverlapCriterion(String loPropertyName,
String hiPropertyName,
Object lo,
Object hi,
boolean includeLo,
boolean includeHi) {
if (lo == null && hi == null)
throw new IllegalArgumentException("lo, hi 모두 null 값이면 질의어를 만들 수 없습니다.");
/*
* Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
private static final String MONGO_OGM_DAO_CLASS_NAME = MongoOgmDao.class.getName();
@Override
@Bean
@Scope("prototype")
public MongoOgmDao hibernateOgmDao() {
MongoOgmDao dao = Local.get(MONGO_OGM_DAO_CLASS_NAME, MongoOgmDao.class);
if (dao == null) {
dao = new MongoOgmDao(sessionFactory());
Local.put(MONGO_OGM_DAO_CLASS_NAME, dao);
package kr.debop4j.core;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import static kr.debop4j.core.Guard.shouldNotBeNull;