com.quamto.jira.data.time.dao.CurrencyDAO Maven / Gradle / Ivy
The newest version!
package com.quamto.jira.data.time.dao;
import com.quamto.core.QException;
import com.quamto.db.DbConnection;
import com.quamto.db.SQLParameter;
import com.quamto.entity.BaseEntity;
import com.quamto.entity.BaseEntityDAO;
import com.quamto.jira.data.time.entity.CurrencyEntity;
import com.quamto.jira.data.time.entity.UserConfigurationEntity;
import com.quamto.jira.data.time.entity.UserCostsHistoryEntity;
import java.sql.ResultSet;
import java.util.List;
/**
* Created by QUAMTO-DEV3 on 08/08/2017.
* [email protected]
*/
public class CurrencyDAO extends BaseEntityDAO {
public CurrencyDAO(DbConnection dbConnection){
super(dbConnection, "qji_currency", "cur_id", CurrencyDAO.class);
}
/**
* Get an instance of the entity with data loaded according to Id provided
*/
@Override
public CurrencyEntity get(Long id) throws QException {
CurrencyEntity entity = null;
try {
entity = (CurrencyEntity)getEntityLoaded(id);
} catch (Exception e) {
throw new QException(e, QException.ExceptionType.LoadData_err, subClassName + "-get");
}
return entity;
}
/**
* Make assignments of fields and values of entity to be used in
* insertion and update database operations
*/
@Override
public void loadQueryParameters(BaseEntity entity)
throws QException {
try {
CurrencyEntity ent = (CurrencyEntity) entity;
addQueryParameter(entityIdFieldName, ent.getID(), SQLParameter.SQLDataType.Long_sdt);
addQueryParameter("cur_id_currency", ent.getIdCurrency(), SQLParameter.SQLDataType.Long_sdt);
addQueryParameter("cur_id_owner", ent.getIdOwner(), SQLParameter.SQLDataType.Long_sdt);
} catch (Exception e) {
throw new QException(e, QException.ExceptionType.LoadData_err, subClassName + "-loadQueryParameters");
}
}
/**
* Gets currency of the owner
* @return Return current current the owner in the database
*/
public CurrencyEntity getCurrencyOwner(Long idOwner) throws QException {
CurrencyEntity entity = null;
try {
ResultSet rs = getResultSet();
String query = "SELECT * "
+ " FROM " + entityTableName
+ " WHERE cur_id_owner = " +idOwner;
rs = dbOperator.getResultSet(query);
while(rs.next()){
entity = loadEntityAttributesFromRs(rs);
}
} catch (Exception e) {
throw new QException(e, QException.ExceptionType.LoadData_err, subClassName + "-getCurrencyOwner");
}
return entity;
}
/**
* Load the values of ResultSet of table from entity in to returned object.
*/
@Override
public CurrencyEntity loadEntityAttributesFromRs(ResultSet rs) throws QException {
CurrencyEntity entity = new CurrencyEntity();
try {
entity.setID(rs.getLong(entityIdFieldName));
entity.setIdCurrency(rs.getLong("cur_id_currency"));
entity.setIdOwner(rs.getLong("cur_id_owner"));
} catch (Exception e) {
throw new QException(e, QException.ExceptionType.LoadData_err, subClassName + "-loadEntityAttributesFromRs");
}
return entity;
}
@Override
public void close() throws Exception {
}
@Override
public List> getAll() throws QException {
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy