我遇到了一个问题。我不知道如何在不将后记留空的情况下删除行。
我正在使用Apache-POI 3.9,使用下一个代码时出现错误:
public List<MeterInfo> addToList(String patternt) throws ParseException, IOException {
List<Object> data = new ArrayList<Object>();
int lastRowNum = sheet.getLastRowNum();
Row row;
for(int i = 0; i < lastRowNum; i++){
row = sheet.getRow(i);
if(patternt.equals(getCurrentString(row))){
data.add(getDataFromRow(row));
sheet.removeRow(row);
sheet.shiftRows(row.getRowNum() + 1, row.getRowNum() + 1, -1);
}
}
saveWorkbook(new File("blabla.xlsx"));
return data;
}
Run Code Online (Sandbox Code Playgroud)
更新版本:
我找到了解决方案:https : //stackoverflow.com/a/3554129/6812826,但是由于每个删除行都会减少lastRowNum,所以我得到了空指针。
这是新版本:
public List<Object> addToList(String pattern) throws ParseException, IOException {
List<Object> data= new ArrayList<Object>();
for (int i = 0; i <= sheet.getLastRowNum(); i++) {
Row row …Run Code Online (Sandbox Code Playgroud) 我正在尝试从数据库获取索引碎片信息。
这里是简洁的 sql 查询:
var result = await _dbConnection.QueryAsync<IndexFragmentationModel>($@"
select
a.index_id as Id, name as Name, avg_fragmentation_in_percent as FragmentationPercent
from sys.dm_db_index_physical_stats (DB_ID(N'@dbName'), OBJECT_ID(N'@tableName'), null, null, null) as a
join sys.indexes as b on a.object_id = b.object_id and a.index_id = b.index_id;
", new
{
dbName = dbName,
tableName = tableName
});
return result.ToList();
Run Code Online (Sandbox Code Playgroud)
参数没有传递到预期的位置。
有人可以建议吗 - 也许还有另一种方法可以通过它们?
我遇到了转换器无法处理 JSON 对象的问题。
我在数据库中有两个对象。关系一对多。
我有一个包含许多服务的 AutoService。
我正在尝试使用邮递员将 JSON 对象发送到我的服务器 - 我收到一个错误:
WARN org.springframework.http.converter.json.MappingJackson2HttpMessageConverter - Failed to evaluate Jackson deserialization for type [[simple type, class com.webserverconfig.user.entity.AutoService]]: java.lang.IllegalArgumentException: Can not handle managed/back reference 'defaultReference': no back reference property found from type [collection type; class java.util.List, contains [simple type, class com.webserverconfig.user.entity.Service]]
Run Code Online (Sandbox Code Playgroud)
接下来的两个类代表我的模型:
类自动服务:
@Entity
@Table(name = "AutoRate")
public class AutoService {
public AutoService() {
}
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
private long id;
@Column(name = "serviceName", nullable = …Run Code Online (Sandbox Code Playgroud)