[Seasar-user:20185] Re: [Kuina-Dao]エンティティのプロパティを条件とする検索の引数でのソート順指定
Inamine Morihiko
[E-MAIL ADDRESS DELETED]
2010年 9月 24日 (金) 13:57:43 JST
いつもお世話になっています
稲嶺です
早速の対応、どうもありがとうございます
> Dao のコードを見せてください.
Daoのソースです
------------------------------------------------------
package aaaaReceipt.dao;
import aaaaReceipt.dto.MaxRecceiptNoDto;
import aaaaReceipt.entity.ReceiptInfo;
import java.util.List;
import org.seasar.kuina.dao.Orderby;
import org.seasar.kuina.dao.OrderbySpec;
public interface ReceiptInfoDao {
public List<ReceiptInfo> findAll();
public ReceiptInfo find(Integer receiptSeq);
public void persist(ReceiptInfo info);
public ReceiptInfo merge(ReceiptInfo info);
public void remove(ReceiptInfo info);
public boolean contains(ReceiptInfo info);
public void refresh(ReceiptInfo info);
public void readLock(ReceiptInfo info);
public void writeLock(ReceiptInfo info);
public List<ReceiptInfo> findByEtc(ReceiptInfo rep);
@Orderby("receiptNo DESC")
public List<ReceiptInfo> findByEtcDesc(ReceiptInfo rep);
public List<ReceiptInfo> findByEtcOrder(ReceiptInfo rep,OrderbySpec
ord);
public MaxRecceiptNoDto getMaxReceiptNo(String receiptNo);
-----------------------------------------------------------------------
動作確認ソースです
------------------------------------------------------------------------
package aaaaReceipt.dao;
import aaaaReceipt.entity.ContactKbn;
import aaaaReceipt.entity.ReceiptInfo;
import java.util.List;
import javax.annotation.Resource;
import org.seasar.extension.unit.S2TestCase;
import org.seasar.kuina.dao.OrderbySpec;
import org.seasar.kuina.dao.OrderingSpec;
public class testDesc extends S2TestCase {
@Resource
ReceiptInfoDao receDao;
@Resource
ContactKbnDao ConkDao;
@Override
protected void setUp() throws Exception {
super.setUp();
include("app.dicon");
}
public void testFindTx() throws Exception{
ContactKbn ConK ;
ReceiptInfo receI= new ReceiptInfo();
OrderbySpec orderbySpec= new OrderbySpec("receiptNo",
OrderingSpec.DESC);
ConK = ConkDao.find(0);
receI.setContactKbn(ConK);
List<ReceiptInfo> receL = receDao.findByEtcOrder(receI,
orderbySpec);
for (ReceiptInfo receN : receL) {
System.out.println(receN.getReceiptNo() );
}
}
}
------------------------------------------------------------------------
Entity(ReceiptInfo)のソースです
-----------------------------------------------------------------------
package aaaaReceipt.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name="RECEIPT_INFO")
public class ReceiptInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "RECEIPT_SEQ")
private Integer receiptSeq;
@Column(name = "RECEIPT_NO")
private String receiptNo;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "RECEIPT_DATE")
private Date receiptDate;
//@Column(name = "RECEIPT_TYPE_KBN")
//private String receiptTypeKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "RECEIPT_TYPE_KBN")
private ReceiptTypeKbn receiptTypeKbn;
//@Column(name = "OPERATOR_ID")
//private Integer operatorId;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "OPERATOR_ID")
private LoginMst loginMst;
//@Column(name = "CONTACT_TYPE_KBN")
//private String contactTypeKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "CONTACT_TYPE_KBN")
private ContactTypeKbn contactTypeKbn;
@Column(name = "COMPANY_NAME")
private String companyName;
@Column(name = "NOVICE_NAME")
private String noviceName;
@Column(name = "REGIST_NO")
private String registNo;
//@Column(name = "PRODUCT_COMPANY_KBN")
//private Integer productCompanyKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "PRODUCT_COMPANY_KBN")
private ProductCompanyKbn productCompanyKbn;
//@Column(name = "CONTACT_KBN")
//private Integer contactKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "CONTACT_KBN")
private ContactKbn contactKbn;
//@Column(name = "PRODUCT_TYPE_KBN")
//private Integer productTypeKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "PRODUCT_TYPE_KBN")
private ProductTypeKbn productTypeKbn;
//@Column(name = "PRODUCT_NAME_KBN")
//private String productNameKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "PRODUCT_NAME_KBN")
private ProductNameKbn productNameKbn;
//@Column(name = "OS_TYPE_KBN")
//private Integer osTypeKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "OS_TYPE_KBN")
private OsTypeKbn osTypeKbn;
@Column(name = "CONTACT_DETAILS")
private String contactDetails;
@Column(name = "DISPOSE_DETAILS")
private String disposeDetails;
private String memo;
//@Column(name = "PROGRESS_KBN")
//private Integer progressKbn;
@ManyToOne(fetch = FetchType.LAZY )
@JoinColumn(name = "PROGRESS_KBN")
private ProgressKbn progressKbn;
@Column(name = "SUPPORT_TIME")
private Integer supportTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "INSERT_DATE")
private Date insertDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDATE_DATE")
private Date updateDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "COMPLETE_DATE")
private Date completeDate;
public Integer getReceiptSeq() {
return receiptSeq;
}
public void setReceiptSeq(Integer receiptSeq) {
this.receiptSeq = receiptSeq;
}
public String getReceiptNo() {
return receiptNo;
}
public void setReceiptNo(String receiptNo) {
this.receiptNo = receiptNo;
}
public Date getReceiptDate() {
return receiptDate;
}
public void setReceiptDate(Date receiptDate) {
this.receiptDate = receiptDate;
}
public ReceiptTypeKbn getReceiptTypeKbn() {
return receiptTypeKbn;
}
public void setReceiptTypeKbn(ReceiptTypeKbn receiptTypeKbn) {
this.receiptTypeKbn = receiptTypeKbn;
}
public LoginMst getLoginMst() {
return loginMst;
}
public void setLoginMst(LoginMst loginMst) {
this.loginMst = loginMst;
}
public ContactTypeKbn getContactTypeKbn() {
return contactTypeKbn;
}
public void setContactTypeKbn(ContactTypeKbn contactTypeKbn) {
this.contactTypeKbn = contactTypeKbn;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getNoviceName() {
return noviceName;
}
public void setNoviceName(String noviceName) {
this.noviceName = noviceName;
}
public String getRegistNo() {
return registNo;
}
public void setRegistNo(String registNo) {
this.registNo = registNo;
}
public ProductCompanyKbn getProductCompanyKbn() {
return productCompanyKbn;
}
public void setProductCompanyKbn(ProductCompanyKbn
productCompanyKbn) {
this.productCompanyKbn = productCompanyKbn;
}
public ContactKbn getContactKbn() {
return contactKbn;
}
public void setContactKbn(ContactKbn contactKbn) {
this.contactKbn = contactKbn;
}
public ProductTypeKbn getProductTypeKbn() {
return productTypeKbn;
}
public void setProductTypeKbn(ProductTypeKbn productTypeKbn) {
this.productTypeKbn = productTypeKbn;
}
public ProductNameKbn getProductNameKbn() {
return productNameKbn;
}
public void setProductNameKbn(ProductNameKbn productNameKbn) {
this.productNameKbn = productNameKbn;
}
public OsTypeKbn getOsTypeKbn() {
return osTypeKbn;
}
public void setOsTypeKbn(OsTypeKbn osTypeKbn) {
this.osTypeKbn = osTypeKbn;
}
public String getContactDetails() {
return contactDetails;
}
public void setContactDetails(String contactDetails) {
this.contactDetails = contactDetails;
}
public String getDisposeDetails() {
return disposeDetails;
}
public void setDisposeDetails(String disposeDetails) {
this.disposeDetails = disposeDetails;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public ProgressKbn getProgressKbn() {
return progressKbn;
}
public void setProgressKbn(ProgressKbn progressKbn) {
this.progressKbn = progressKbn;
}
public Integer getSupportTime() {
return supportTime;
}
public void setSupportTime(Integer supportTime) {
this.supportTime = supportTime;
}
public Date getInsertDate() {
return insertDate;
}
public void setInsertDate(Date insertDate) {
this.insertDate = insertDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Date getCompleteDate() {
return completeDate;
}
public void setCompleteDate(Date completeDate) {
this.completeDate = completeDate;
}
}
-----------------------------------------------------------------------
Entity(ContactKbn)のソースです
-----------------------------------------------------------------------
package aaaaReceipt.entity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name="CONTACT_KBN")
public class ContactKbn {
@Id
@GeneratedValue
@Column(name = "CONTACT_KBN")
private Integer contactKbn;
private String name;
@OneToMany(mappedBy= "contactKbn")
private List<ReceiptInfo> receiptInfo;
public Integer getContactKbn() {
return contactKbn;
}
public void setContactKbn(Integer contactKbn) {
this.contactKbn = contactKbn;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<ReceiptInfo> getReceiptInfo(){
return receiptInfo;
}
public void setReceiptInfo(List<ReceiptInfo> receiptInfo){
this.receiptInfo = receiptInfo;
}
}
-----------------------------------------------------------------------
>
> 動的にソート順を指定する場合の説明は以下にあります.
>
> http://kuina.seasar.org/ja/user_guide/query.html#特別な意味を持つ引数名およびDTOのプロパティ名
>
>
Seasar-user メーリングリストの案内