블로그 이미지
올해목표 // 10월 어학연수 떠나자~ 자수씨

카테고리

전체글 (1457)
Brand New! (28)
주절주절 (213)
MOT (11)
해외쇼핑 (49)
쇼핑노트 (150)
취미생활 (94)
iPhone (4)
Eclipse (121)
Google (83)
Spring (31)
JAVA (176)
JavaScript (59)
WEB (49)
Database (20)
OS (26)
Tools (8)
Tips (26)
IT정보 (1)
Book (21)
Programming (37)
외부행사 (43)
주변인들 (17)
여행노트 (60)
학교생활 (30)
회사생활 (52)
사회생활 (5)
외국어공부 (12)
잡동사니 (30)
Total
Today
Yesterday
 
05-19 11:09
 

달력

« » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
 

최근에 올라온 글

최근에 달린 댓글


2011/01/29 - [JAVA/Hibernate] - 하이버네이트... 해당 쿼리에 대한 전체 카운트 가지고 오기

위의 글과 같이 전체 카운트를 가지고 오는 부분을 추가했더니... 대략 18번의 쿼리가 수행된 후에 DB 수행작업이 먹통이 되어버렸습니다. 처음에는 원인을 찾지 못하다가, 세션을 가져온 후 반환을 하지 않는 것을 확인하고 코드를 수정하지 않는 선에서 해결책을 찾았습니다.




하이버네이트 프로퍼티에 hibernate.connection.release_mode 의 값을 after_transaction 로 설정하면 굳이 세션을 가져온 후 관리를 하지 않아도 되더군요... 꼭 좋은 방법은 아니지만 위와 같은 방법도 있습니다.

Posted by 자수씨
, |


전체 카운트를 어떻게 가지고 올까 고민을 하다가... 찾아보니 아래와 같이 처리를 하면 되더군요...



DetachedCriteria 를 재사용해서 쓰려다 보니 위와 같은 형식으로 작성했습니다. 헐... 근데 저렇게 사용하니 원하는 결과가 안나오더군요... 그래서 결국 DetachedCriteria 를 새로 만들어 같은 값을 설정한 후 사용하였습니다.

시간이 없어 간만에 작성하는... 포스팅...

Posted by 자수씨
, |

iBATIS 를 이용한지는 3년정도가 지났고, Hibernate 는 올해 처음 맛을 보았습니다.

두가지 모두 각각의 장점들이 명확한지라, 어느 한쪽만 택하기가 아쉬운 점이 있습니다.

그래서 다음번 프로젝트 때는 두가지를 병행하여 사용해볼까 합니다.

CRUD 는 하이버네이트를 이용하고, 테이블 간의 조인이 필요로 할 경우에는 iBATIS 를 이용해보려 합니다.

아마도 테이블 설계가 잘 되어 있고, DB 내에 펑션이나 프로시저 처럼 로직이 들어가 있지 않다면 iBATIS 를 이용할 일이 거의 없겠지만 현실은 항상 우리편이 아니기 때문에 iBATIS 도 적절하게 사용하는 것이 생산성 향상에 도움이 될 것으로 생각합니다.

어차피 DataSource 는 공유해서 사용할 것이고... 문제가 될만한게 없겠죠???

Posted by 자수씨
, |


<!DOCTYPE pubdoc SYSTEM "pubdoc.dtd">

위와 같이 XML 에 dtd 가 정의되어 있는 경우 JAXB 로 unmarshal 을 할 경우 dtd 의 위치가 명확하지 않아 재대로 unmarshal 이 되지 않을 수 있습니다.

좀 더 안전한 시스템을 위해서는 명확하게 정의해야 하는데요... 아래와 같은 방법을 사용합니다.



XMLReader 객체에 설정된 EntityResolver 를 통해 해당 dtd 와 관련된 정보들을 InputSource 로 참조할 수 있도록 처리하는 것 입니다.

EntityResolver 의 resolveEntity 메소드는 필요로 하는 리소스들을 두번째 파라미터인 syustemId 로 넘기게 됩니다.

즉, "C:/JAVA/Temp" 폴더에서 실행을 한다면 "pubdoc.dtd" 는 "C:/JAVA/Temp/pubdoc.dtd" 에서 찾게 됩니다. 해당 systemId 를 적당히 잘라내어 클래스패스 내에 리소스의 위치와 결합시켜서 로드하는 방식을 사용하였습니다.


먼가 systemId 자르는 것이 찝찌름 하지만 정상구동 확인하였습니다.

Posted by 자수씨
, |

JRebel 을 쓰면서 좀 불편했던 점이 rebel.xml 파일에 로컬 환경에 따라 경로가 다르게 되는데, 이 파일까지 버전관리를 하다보니 최초에 도입하신 분 외에는 커밋하기 어려운 점이 있었습니다.

구글링 몇 번으로 해결책을 찾았습니다.




위와 같은 설정이 있을 경우 "c:\myWorkspace" 의 경로는 로컬 환경의 경로입니다. JRebel 에서 제공해주는 변수를 통해 설정이 가능합니다.

아래와 같이 VM 파라미터를 추가하고
-Dmyproject.root=c:\myWorkspace

아래와 같이 rebel.xml 을 설정하면, 로컬 환경에 구애받지 않고 버전관리가 가능합니다.



참고사이트: http://www.zeroturnaround.com/reference-manual/app.html

Posted by 자수씨
, |

Java 로 SVN 가지고 놀기~

JAVA / 2011. 1. 14. 09:57

데일리 빌드 프로그램을 만들기 위해 자바로 서브버전 리파지토리에서 데이터를 가지고 오는 것이 필요하였습니다.

이클립스 서브버전 커넥터에서 많이 보았던 SVNKit(http://www.svnkit.com/) 을 이용해보기로 하였습니다.

테스트 기반은 메이븐으로 이루어져 있으며, SVNKit 의 최신버전은 1.3.5 의 디펜던시를 추가하였습니다.



테스트 코드는 다음과 같습니다. 특정 리파지토리에 연결하여 최신(HEAD) 리비전 체크아웃 또는 업데이트 받기 입니다.

1. 각 프로토콜에 대한 SVN 라이브러리를 초기화합니다.



2. 리파지토리에 연결에 필요한 객체를 생성합니다.
 >> SVNURL: 리파지토리 주소 관련 객체
 >> SVNClientManager: 인증관련 정보 설정 객체



3. 해당 리파지토리를 체크아웃합니다.



3-1. 로컬 리파지토리를 업데이트하는 기능은 다음과 같습니다.



테스트 코드를 돌리면서 로컬에 파일이 내려지는 걸 보니 마음이 뿌듯해집니다.



Posted by 자수씨
, |

메이븐을 이용하여 기본적으로 제공해주는 webapp archetype 으로 프로젝트를 생성하게 되면 이클립스에서 웹 프로젝트로 인식이 되지 않습니다.

프로젝트도 아래와 같이 단순하게 구성되어 있습니다.



pom.xml 에 wtp 와 관련된 plugin 설정을 합니다.



그런 후에 eclipse:eclipse 를 goal 로 빌드를 하게 되면~




[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building gwtbuilder-webapp Maven Webapp
[INFO]    task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: D:\**********
[INFO] no substring wtp server match.
[INFO] Using as WTP server : Tomcat v6.0 as wiseOne
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] @@@ TRUE - Manifests are equal
[INFO] Not writing Manifest file as it is unchanged: D:\**********\gwtbuilder-webapp\src\main\webapp\META-INF\MANIFEST.MF
[INFO] File D:\**********\gwtbuilder-webapp\.project already exists.
       Additional settings will be preserved, run mvn eclipse:clean if you want old settings to be removed.
[INFO] Wrote Eclipse project for "gwtbuilder-webapp-0.0.1-SNAPSHOT" to D:\**********\gwtbuilder-webapp.
[INFO]
       Sources for some artifacts are not available.
       Please run the same goal with the -DdownloadSources=true parameter in order to check remote repositories for sources.
       List of artifacts without a source archive:
         o junit:junit:3.8.1
       Javadoc for some artifacts is not available.
       Please run the same goal with the -DdownloadJavadocs=true parameter in order to check remote repositories for javadoc.
       List of artifacts without a javadoc archive:
         o junit:junit:3.8.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Jan 12 16:09:35 KST 2011
[INFO] Final Memory: 8M/19M

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building gwtbuilder-webapp Maven Webapp
[INFO]    task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: D:\**********
[INFO] no substring wtp server match.
[INFO] Using as WTP server : Tomcat v6.0 as *******
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] File D:\**********\gwtbuilder-webapp\.project already exists.
       Additional settings will be preserved, run mvn eclipse:clean if you want old settings to be removed.
[INFO] Wrote Eclipse project for "gwtbuilder-webapp-0.0.1-SNAPSHOT" to D:\**********\gwtbuilder-webapp.
[INFO]
       Sources for some artifacts are not available.
       Please run the same goal with the -DdownloadSources=true parameter in order to check remote repositories for sources.
       List of artifacts without a source archive:
         o junit:junit:3.8.1
       Javadoc for some artifacts is not available.
       Please run the same goal with the -DdownloadJavadocs=true parameter in order to check remote repositories for javadoc.
       List of artifacts without a javadoc archive:
         o junit:junit:3.8.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Jan 12 16:27:06 KST 2011
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------



웹 프로젝트와 관련된 설정들이 추가되게 됩니다.




이제 개발 고고씽~

Posted by 자수씨
, |

log4j.properties 파일을 클래스패스에 넣으면 되겠지 했는데 잘 안잡혀서 찾아보니 시스템 프로퍼티로 위치를 별도로 설정할 수 있었습니다.

java -Dlog4j.configuration=conf/log4j.properties -classpath ...


위의 방식은 클래스패스에 있는 위치만 바꿔주는 것이고 실제 파일 경로로 잡아주기 위해서는 file:/// 를 이용합니다.

java -Dlog4j.configuration=file:///conf/log4j.properties -classpath ...


우휴;;;

Posted by 자수씨
, |

오늘 메이븐 쪽으로 찾다보니 익숙한 Ant 와 비교하는 표를 발견하였습니다.
(http://maven.apache.org/plugins/maven-antrun-plugin/usage.html)

Ant Expression Maven Expression
Built-in Tasks  
Ant maven-antrun-plugin
AntCall maven-antrun-plugin
Available profiles
BUnzip2 maven-assembly-plugin
BZip2 maven-assembly-plugin
Chmod maven-assembly-plugin
Condition profiles
Copy maven-resources-plugin
Dependset maven-dependency-plugin
Ear maven-ear-plugin
Filter maven-resources-plugin
Note: Filter uses the @...@ token while maven-resources-plugin uses the \$... token
FixCRLF maven-resources-plugin
GenKey maven-jar-plugin
GUnzip maven-assembly-plugin
GZip maven-assembly-plugin
Jar maven-jar-plugin
Javac maven-compiler-plugin
Javadoc/Javadoc2 maven-javadoc-plugin
LoadProperties maven-resources-plugin
Manifest maven-jar-plugin
Property maven-resources-plugin
Replace maven-resources-plugin
Note: Replace can specify its token while maven-resources-plugin uses the \$... token
Tar maven-assembly-plugin
Unjar maven-assembly-plugin
Untar maven-assembly-plugin
Unwar maven-assembly-plugin
Unzip maven-assembly-plugin
War maven-war-plugin
Zip maven-assembly-plugin
Optional Tasks  
Antlr maven-antlr-plugin
Depend maven-dependency-plugin
EJB Tasks maven-ejb-plugin
FTP maven-deploy-plugin
Note: maven-deploy-plugin can only deploy unto the FTP
JavaCC maven-compiler-plugin
JJDoc maven-compiler-plugin
JJTree maven-compiler-plugin
JUnit maven-surefire-plugin
JUnitReport maven-surefire-report-plugin
ServerDeploy maven-deploy-plugin
Setproxy maven-deploy-plugin
Translate maven-resources-plugin
Note: Translate can specify its own tokens and can have a different encoding scheme for reading and writing files. maven-resources-plugin however uses the \$... annotation only and has only one encoding scheme for reading and writing


나중에 도움이 될 것 같아 정리합니다.

Posted by 자수씨
, |

메이븐을 쓰면서도 Ant 를 이용하여 빌드하는 경우도 발생할 수 있습니다.

이 때 좀 애매한 상황이 클래스패스 설정 부분일 것 입니다.

이런 상황에서 원하는 기능을 제공해 주는 것이 있습니다. Maven Ant Tasks (http://maven.apache.org/ant-tasks/index.html)

아래 페이지에서 관련 라이브러리를 받은 후에 ant 에 task 를 추가합니다.
http://maven.apache.org/ant-tasks/download.html 




사용법은 아래와 같습니다.



Ant 클래스패스를 정의한 후에 자바 프로그램을 실행하거나 컴파일을 할 때 패스를 지정하여 사용합니다.

라이브러리를 확인하는 절차 때문에 초기 실행에 시간이 약간 걸리지만 Maven 과 Ant 를 함께 잘 어울려서 쓸수 있는 방법 중 하나인 것 같습니다.

Posted by 자수씨
, |

글 보관함

최근에 받은 트랙백