Member Asset DAO and VO.
This commit is contained in:
parent
667960ee75
commit
d27eb14da4
@ -0,0 +1,33 @@
|
|||||||
|
package de.hsadmin.dao.customer;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
|
||||||
|
import de.hsadmin.bo.customer.MemberAsset;
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.service.customer.MemberAssetVO;
|
||||||
|
|
||||||
|
public class MemberAssetDao {
|
||||||
|
|
||||||
|
@PersistenceContext(name="hsar")
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
public MemberAsset findMemberAssetByValues(MemberAssetVO prototype) throws UserException, TechnicalException {
|
||||||
|
// TODO MHOENNIG -> PHORMANNS: warum werden immer alle verglichen? OptimisticLocking?
|
||||||
|
// (p.s. code analog zu Beispielen von dir)
|
||||||
|
final Query query = entityManager.createQuery("SELECT s FROM MemberAsset s " +
|
||||||
|
"WHERE s.customer.name = :customer " +
|
||||||
|
" AND m.action = :action " +
|
||||||
|
" AND m.date.name = :date" +
|
||||||
|
" AND m.amount = :amount" +
|
||||||
|
" AND m.comment = :comment");
|
||||||
|
query.setParameter("customer", prototype.get("customer").getValue());
|
||||||
|
query.setParameter("action", prototype.get("action").getValue());
|
||||||
|
query.setParameter("date", prototype.get("date").getValue());
|
||||||
|
query.setParameter("amount", prototype.get("amount").getValue());
|
||||||
|
query.setParameter("comment", prototype.get("comment").getValue());
|
||||||
|
return (MemberAsset) query.getSingleResult();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.module.ValueObject;
|
||||||
|
import de.hsadmin.module.impl.AbstractVO;
|
||||||
|
import de.hsadmin.module.property.ReadWrite;
|
||||||
|
import de.hsadmin.module.property.ReadWritePolicy;
|
||||||
|
import de.hsadmin.module.property.Required;
|
||||||
|
import de.hsadmin.module.property.Search;
|
||||||
|
import de.hsadmin.module.property.SearchPolicy;
|
||||||
|
import de.hsadmin.module.property.mapping.DefaultEnumPersistentObjectMapper;
|
||||||
|
import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper;
|
||||||
|
import de.hsadmin.module.property.mapping.Mapping;
|
||||||
|
import de.hsadmin.module.property.mapping.ReferredStringPersistentObjectMapper;
|
||||||
|
|
||||||
|
public class MemberAssetVO extends AbstractVO implements ValueObject {
|
||||||
|
|
||||||
|
@Mapping(boMapping=ReferredStringPersistentObjectMapper.class,
|
||||||
|
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||||
|
boMappingPath="customer.name")
|
||||||
|
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||||
|
@Required(true)
|
||||||
|
@Search(SearchPolicy.EQUALS)
|
||||||
|
private String customer;
|
||||||
|
|
||||||
|
@Mapping(boMapping=DefaultEnumPersistentObjectMapper.class,
|
||||||
|
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||||
|
boMappingPath="customer.name")
|
||||||
|
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||||
|
@Required(true)
|
||||||
|
@Search(SearchPolicy.EQUALS)
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||||
|
@Required(true)
|
||||||
|
@Search(SearchPolicy.COMPARE)
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||||
|
@Required(true)
|
||||||
|
@Search(SearchPolicy.COMPARE)
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||||
|
@Required(true)
|
||||||
|
@Search(SearchPolicy.LIKE)
|
||||||
|
private String comment;
|
||||||
|
|
||||||
|
public MemberAssetVO() throws TechnicalException {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomer(String customer) {
|
||||||
|
this.customer = customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(BigDecimal amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MemberShareVO [customer=" + customer + ", action=" + action + ", date=" + date + ", amount="
|
||||||
|
+ amount + ", comment=" + comment + "]";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user