Search in sources :

Example 36 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project ovirt-engine by oVirt.

the class TagDaoImpl method getTagVmByTagIdAndByVmId.

@Override
public TagsVmMap getTagVmByTagIdAndByVmId(Guid tagId, Guid vmId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("tag_id", tagId).addValue("vm_id", vmId);
    RowMapper<TagsVmMap> mapper = (rs, rowNum) -> {
        TagsVmMap entity = new TagsVmMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setVmId(getGuidDefaultEmpty(rs, "vm_id"));
        entity.setDefaultDisplayType((Integer) rs.getObject("DefaultDisplayType"));
        return entity;
    };
    return getCallsHandler().executeRead("GetTagVmByTagIdAndByvmId", mapper, parameterSource);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Guid(org.ovirt.engine.core.compat.Guid) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) TagsType(org.ovirt.engine.core.common.businessentities.TagsType) SQLException(java.sql.SQLException) List(java.util.List) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) ResultSet(java.sql.ResultSet) Tags(org.ovirt.engine.core.common.businessentities.Tags) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap)

Example 37 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project ovirt-engine by oVirt.

the class TagDaoImpl method getTagVdsByTagIdAndByVdsId.

@Override
public TagsVdsMap getTagVdsByTagIdAndByVdsId(Guid tagId, Guid vdsId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("tag_id", tagId).addValue("vds_id", vdsId);
    RowMapper<TagsVdsMap> mapper = (rs, rowNum) -> {
        TagsVdsMap entity = new TagsVdsMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setVdsId(getGuidDefaultEmpty(rs, "vds_id"));
        return entity;
    };
    return getCallsHandler().executeRead("GetTagVdsBytagIdAndByVdsId", mapper, parameterSource);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Guid(org.ovirt.engine.core.compat.Guid) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) TagsType(org.ovirt.engine.core.common.businessentities.TagsType) SQLException(java.sql.SQLException) List(java.util.List) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) ResultSet(java.sql.ResultSet) Tags(org.ovirt.engine.core.common.businessentities.Tags) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap)

Example 38 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project ovirt-engine by oVirt.

the class TagDaoImpl method getTagUserByTagIdAndByuserId.

@Override
public TagsUserMap getTagUserByTagIdAndByuserId(Guid tagId, Guid userId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("tag_id", tagId).addValue("user_id", userId);
    RowMapper<TagsUserMap> mapper = (rs, rowNum) -> {
        TagsUserMap entity = new TagsUserMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setUserId(getGuidDefaultEmpty(rs, "user_id"));
        return entity;
    };
    return getCallsHandler().executeRead("GetTagUserByTagIdAndByuserId", mapper, parameterSource);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Guid(org.ovirt.engine.core.compat.Guid) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) TagsType(org.ovirt.engine.core.common.businessentities.TagsType) SQLException(java.sql.SQLException) List(java.util.List) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) ResultSet(java.sql.ResultSet) Tags(org.ovirt.engine.core.common.businessentities.Tags) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap)

Example 39 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project ovirt-engine by oVirt.

the class TagDaoImpl method getTagVmMapByVmIdAndDefaultTag.

@Override
public List<TagsVmMap> getTagVmMapByVmIdAndDefaultTag(Guid vmid) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_id", vmid);
    RowMapper<TagsVmMap> mapper = (rs, rowNum) -> {
        TagsVmMap entity = new TagsVmMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setVmId(getGuidDefaultEmpty(rs, "vm_id"));
        entity.setDefaultDisplayType((Integer) rs.getObject("DefaultDisplayType"));
        return entity;
    };
    return getCallsHandler().executeReadList("GetnVmTagsByVmIdAndDefaultTag", mapper, parameterSource);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Guid(org.ovirt.engine.core.compat.Guid) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) TagsType(org.ovirt.engine.core.common.businessentities.TagsType) SQLException(java.sql.SQLException) List(java.util.List) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) ResultSet(java.sql.ResultSet) Tags(org.ovirt.engine.core.common.businessentities.Tags) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap)

Example 40 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project spring-data-jdbc by spring-projects.

the class JdbcQueryLookupStrategyUnitTests method prefersDeclaredQuery.

// GH-1061
@Test
void prefersDeclaredQuery() {
    RowMapper<? extends NumberFormat> numberFormatMapper = mock(RowMapper.class);
    QueryMappingConfiguration mappingConfiguration = new DefaultQueryMappingConfiguration().registerRowMapper(NumberFormat.class, numberFormatMapper);
    RepositoryQuery repositoryQuery = getRepositoryQuery("annotatedQueryWithQueryAndQueryName", mappingConfiguration);
    repositoryQuery.execute(new Object[] {});
    verify(operations).queryForObject(eq("some SQL"), any(SqlParameterSource.class), any(RowMapper.class));
}
Also used : RepositoryQuery(org.springframework.data.repository.query.RepositoryQuery) QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) DefaultQueryMappingConfiguration(org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) DefaultQueryMappingConfiguration(org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.jupiter.api.Test)

Aggregations

RowMapper (org.springframework.jdbc.core.RowMapper)51 ResultSet (java.sql.ResultSet)27 SQLException (java.sql.SQLException)16 List (java.util.List)14 Named (javax.inject.Named)8 Singleton (javax.inject.Singleton)8 Test (org.junit.jupiter.api.Test)8 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)8 Guid (org.ovirt.engine.core.compat.Guid)7 QueryMappingConfiguration (org.springframework.data.jdbc.repository.QueryMappingConfiguration)7 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Tags (org.ovirt.engine.core.common.businessentities.Tags)5 TagsTemplateMap (org.ovirt.engine.core.common.businessentities.TagsTemplateMap)5 TagsType (org.ovirt.engine.core.common.businessentities.TagsType)5 TagsUserGroupMap (org.ovirt.engine.core.common.businessentities.TagsUserGroupMap)5 TagsUserMap (org.ovirt.engine.core.common.businessentities.TagsUserMap)5 TagsVdsMap (org.ovirt.engine.core.common.businessentities.TagsVdsMap)5 TagsVmMap (org.ovirt.engine.core.common.businessentities.TagsVmMap)5 DataAccessException (org.springframework.dao.DataAccessException)5