[Hibernate] criteria or 조건
예) select * from table1 where con1 = 1 or con2 like '2%';
Criteria crit = session.createCriteria(Product.class);
Criterion con1 = Restrictions.eq("con1", 1);
Criterion con2 = Restrictions.like("con2","2%");
LogicalExpression orExp = Restrictions.or(con1, con2);
crit.add(orExp);
예) select * from table1 where con1 = 1 and (con2 = 2 or con3 = 3);
Disjunction aOrB = Restrictions.disjunction();
aOrB.add(Restrictions.eq("con2", "2"));
aOrB.add(Restrictions.eq("con3", "3"));
crit.add(Restrictions.and(Restrictions.eq("con1", "1"), aOrB));
예) select * from table1 a inner join table2 b on a.id = b.id where a.con1 = 1 and (a.con2 = 2 or b.con2=2);
Criteria crit = session.createCriteria(Product.class);
Criteria critTable2 = crit.createCriteria("table2","b");
crit.add(Restrictions.eq("con1", 1));
crit.add(Restrictions.disjunction().add(Restrictions.eq("con2", 2).add(Restrictions.eq("b.con2",2)));
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2011/10/19 16:23
2011/10/19 16:23
Track this back : http://www.evelyn.pe.kr/kor/trackback/148
[Hibernate] 중복된 row 가 리턴될 때
쿼리 결과 중복된 row 가 발생하는 경우가 있었다.
그러니까~~ distinct 옵션으로 가져오고 싶은데 안되어서 방황하고 있었던 찰라..
역시 구글링으로 나온 간결한 한마디.
criteria.setResultTransformer(Criteria. DISTINCT_ROOT_ENTITY);
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2011/10/19 16:14
2011/10/19 16:14
Track this back : http://www.evelyn.pe.kr/kor/trackback/147
id="${objectValue}" 로 쓰면 숫자로 이루어진 id 등에 콤마가 찍혀서 난감하다.
id="22,153,243,556" 막 이렇게 찍힘.
이때에는 id="${objectValue?string("##0")}" 으로 쓰면 콤마를 제외하고 id="22153243556" 요렇게 나옴.
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2011/10/19 16:10
2011/10/19 16:10
Track this back : http://www.evelyn.pe.kr/kor/trackback/146
[FLEX] Renderer를 이용하여 datagrid 컬럼 헤더에 콤보박스 넣기
아.. 빨리도 한다. 소스 백업..;;Function.as
//datagrid 에 콤보박스 넣는 부분 private function AddColums(addCount:int):void { var columns:Array = setInitColumn(true); for(var i:int = 0; i < addCount; i++) { g_AllColumnArray.push({headerText:"항목선택", dataField:"", xmlIndex:g_ChildIndexOnXml} as Object); var col:DataGridColumn = new DataGridColumn("col" + i + 3); var colRender:ClassFactory = new ClassFactory(RendererComboBox); colRender.properties = {xmlIndex:g_ChildIndexOnXml}; col.headerRenderer = colRender; col.width = 130; columns.push(col); g_ChildIndexOnXml++; }
dataGrid.columns = columns; }
//컬럼이 바뀌었을 때
public function columChanged(item:Object):void
{
if(item != null) g_AllColumnArray[item.xmlIndex] = item;
}
RendererComboBox.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:HBox height="24" xmlns:mx="http://www.adobe.com/2006/mxml " horizontalAlign="center" verticalAlign="middle" horizontalScrollPolicy="off" creationComplete="initApp()"> <mx:Script> <![CDATA[ private var _xmlIndex:int; public function set xmlIndex(value:int):void { _xmlIndex = value; } public function get xmlIndex():int { return _xmlIndex; }
private function Onchange():void { var item:Object = new Object(); item.headerText = lvlLabel.selectedItem.label; item.dataField = lvlLabel.selectedItem.data; item.xmlIndex = _xmlIndex; parentDocument.columChanged(item); } private function initApp():void { lvlLabel.selectedIndex = 0; } ]]> </mx:Script> <mx:ComboBox width="100%" textAlign="left" id="lvlLabel" cornerRadius="0" height="100%" change="Onchange()"> <mx:Object label="항목선택" data=""/> <mx:Object label="전자메일" data="emailId"/> <mx:Object label="회사" data="coNm"/> <mx:Object label="부서" data="coDept"/> <mx:Object label="직함" data="coHandle"/> <mx:Object label="우편번호(회사)" data="coZipCd"/> <mx:Object label="회사주소" data="coAddr1"/> <mx:Object label="회사전화" data="coTelNo"/> <mx:Object label="팩스" data="faxNo"/> <mx:Object label="우편번호(집)" data="homeZipCd"/> <mx:Object label="집주소" data="homeAddr1"/> <mx:Object label="집전화" data="homeTelNo"/> <mx:Object label="홈페이지" data="homepageUrl"/> <mx:Object label="메신저" data="messenger"/> </mx:ComboBox> </mx:HBox>
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2009/09/21 14:29
2009/09/21 14:29
Track this back : http://www.evelyn.pe.kr/kor/trackback/142
검색하다가 발견!! 잘 되려나??
일단 백업해둠
MD5 hash on iPhone with cocoa and Objective-C In beta 7 OpenSSL has been removed from the iPhone SDK. However, MD5 is still available. Simply import CommonCrypto as follows:
#import < CommonCrypto/CommonDigest.h > Then add this C function to your objective-c class between the @implementation and @end statements (if you like). NSString* md5( NSString *str ) { const char *cStr = [str UTF8String]; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5( cStr, strlen(cStr), result ); return [NSString stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ]; } I am sure you can just use NSData for this but this is the way an example was posted on apple forums. Please feel free to add an NSData based solution. Read the post here "http://discussions.apple.com/thread.jspa?threadID=1509152&tstart=96"
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2009/06/24 11:08
2009/06/24 11:08
Track this back : http://www.evelyn.pe.kr/kor/trackback/141
NSString 문자열 길이를 UNICODE byte크기로 알아내기!!
-- 백업 -- 백업 -- 백업 -- 백업 -- 백업 -- 백업 -- 백업 -- 백업 -- NSString *temp = @"test";
printf("%d\n",[temp lengthOfBytesUsingEncoding:NSUnicodeStringEncoding]);
결과는!!
8
-_-b
유니코드로 인코딩해서 strlen으로 변환 하는 뻘짓을 햇다가 안되길래
찾아보니 잇슴.. OTL..
결론은 lengthOfBytesUsingEncoding:
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2009/06/23 15:08
2009/06/23 15:08
Track this back : http://www.evelyn.pe.kr/kor/trackback/140
[코코아 프로그래밍] 바뀐 Interface Builder
어쩐지.. 책보고 할 때 exception 이 난무하더니... OTL.. 출처 : http://milines.egloos.com/1811201 크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2009/04/07 17:20
2009/04/07 17:20
Track this back : http://www.evelyn.pe.kr/kor/trackback/135
[JAXB] 주소록 xmlparser 3. xml 쓰기, 읽기
** 까먹기 전에 정리하자. 프로젝트의 모든 내용을 까발릴 수는 없으니까 요약 정리함. (Spring FrameWork + Flex 통신 중 사용) 1. 쓰기
/** * 참고 코드 : JAXB - 파일 읽기 * @param input : xml 만들 리스트 * @param pw: xml 쓸 곳 ( 여기서는 화면에 ) * @return * @throws JAXBException */ public void writeGroupXML(List input, PrintWriter pw) throws JAXBException, FileNotFoundException { ObjectFactory objFactory = new ObjectFactory(); AddressBook ad = (AddressBook) objFactory.createAddressBook(); AddressBook.Groups grps = objFactory.createAddressBookGroups(); List grpList = grps.getGroup();
for(int i=0; i<input.size(); i++) { GroupType grp = objFactory.createGroupType(); GroupVO gv = new GroupVO(); gv = (GroupVO)input.get(i); grp.setGroupNm(gv.getGroupNm()); grp.setGroupSeqNo(gv.getGroupSeqNo()); grpList.add(grp); } ad.setGroups(grps); JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true)); marshaller.marshal(ad, pw); }
2. 읽기
/** * 참고 코드 : JAXB - 파일 읽기 * @param strFile 파일 경로 + 이름까지 * @return * @throws JAXBException */ public List readXMLFile(String strFile) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance("com.evelyn.msg.xml"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); AddressBook ad= (AddressBook)unmarshaller.unmarshal(new File(strFile)); AddressBook.Buddies bds = ad.getBuddies(); List bdt = bds.getBuddy(); for(int i = 0; i < bdt.size(); i++) { BuddyType bt = (BuddyType)bdt.get(i); } return bdt; }
/** * 참고 코드 : JAXB - XML 문자열 읽기 * @param strXml XML 문자열 * @return * @throws JAXBException */ public List readXML(String strXml) throws JAXBException { if(strXml == "") { logger.info("null string"); return null; } JAXBContext jaxbContext = JAXBContext.newInstance("com.evelyn.msg.xml"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringBuffer xmlStr = new StringBuffer(strXml); AddressBook ad = (AddressBook)unmarshaller.unmarshal(new StreamSource(new StringReader( xmlStr.toString()))); AddressBook.Buddies bds = ad.getBuddies(); List bdt = bds.getBuddy(); return bdt; }
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2008/10/28 11:51
2008/10/28 11:51
Track this back : http://www.evelyn.pe.kr/kor/trackback/127
[JAXB] 주소록 xmlparser 2. xsd 작성, java 파일 생성하기
** 까먹기 전에 정리하자. 프로젝트의 모든 내용을 까발릴 수는 없으니까 요약 정리함. (Spring FrameWork + Flex 통신 중 사용) 1. 주소록 xsd 를 만든다. 주소록 - 그룹 - 버디의 구조.
<?xml version="1.0" encoding="EUC-KR"?>
<xs:schema xmlns:jaxb="
http://java.sun.com/xml/ns/jaxb " xmlns:xs="
http://www.w3.org/2001/XMLSchema " jaxb:version="1.0">
<xs:element name="AddressBook">
<xs:complexType>
<xs:sequence>
<xs:element name="buddies" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="buddy" type="buddyType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groups" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="group" type="groupType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="groupType">
<xs:sequence>
<xs:element name="groupSeqNo">
<xs:simpleType>
<xs:restriction base="xs:long"/>
</xs:simpleType>
</xs:element>
<xs:element name="groupNm">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="buddyType">
<xs:sequence>
<xs:element name="buddyNm">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="hpNo">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9\-]*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="emailId" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
2. 컴파일 한다. 컴파일 방법 참고 -> http://www.evelyn.pe.kr/kor/122 3. 다음의 파일이 생긴다. AddressBook.java BuddyType.java GroupType.java ObjectFactory.java
크리에이티브 커먼즈 라이센스 (
0 )
(
0 )
evelynYun
2008/10/28 11:44
2008/10/28 11:44
Track this back : http://www.evelyn.pe.kr/kor/trackback/126
[JAXB] 주소록 xmlparser 1. JAXB 설치, xsd 컴파일 방법
1. 여기에 가서 Installation 을 다운 받는다https://jaxb.dev.java.net/jaxb20-fcs/
2. 다운 받은 jar를 실행한다.
java -jar JAXB2_20060426.jar
3. 압축이 풀린 곳을 보면 bin/xjc.bat 가 있다. 커맨드창에서 해당 경로로 간 다음 다음처럼 명령어를 친다.
xjc -p <패키지명> <xsd명> -d <파일을 생성할 폴더명>
예> xjc -p com.evelyn.msg.xml msg.xsd -d .
4> com/evelyn/msg/xml 에 java 파일들이 생성된다.
크리에이티브 커먼즈 라이센스
evelynYun
2008/08/26 14:13
2008/08/26 14:13
Track this back : http://www.evelyn.pe.kr/kor/trackback/122
«
2012/02
»
일
월
화
수
목
금
토
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
Total : 185812
Today : 12
Yesterday : 27