
net.kemitix.itunes.medialibrary.LibraryDao Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of itunes-medialibrary Show documentation
Show all versions of itunes-medialibrary Show documentation
Java library for reading/writing to the iTunes MediaLibrary SQLite database
The newest version!
package net.kemitix.itunes.medialibrary;
import java.util.List;
import lombok.Getter;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
@Getter
public abstract class LibraryDao {
private final JdbcTemplate jdbcTemplate;
private final RowMapper rowMapper;
abstract String getSelectAllSql();
abstract String getSelectByIdSql();
public LibraryDao(
JdbcTemplate jdbcTemplate,
RowMapper rowMapper
) {
this.jdbcTemplate = jdbcTemplate;
this.rowMapper = rowMapper;
}
public List selectAll() {
return jdbcTemplate.query(getSelectAllSql(), rowMapper);
}
public T find(long id) {
try {
return jdbcTemplate.queryForObject(getSelectByIdSql(), rowMapper, id);
} catch (EmptyResultDataAccessException e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy