mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-30 01:46:18 +08:00
Use Hibernate framework to operate pojo instance, bye bye SQL strings :)
This commit is contained in:
25
src/main/java/love/sola/netsupport/enums/BlockConverter.java
Normal file
25
src/main/java/love/sola/netsupport/enums/BlockConverter.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package love.sola.netsupport.enums;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class BlockConverter implements AttributeConverter<Block, Integer> {
|
||||
|
||||
@Override
|
||||
public Integer convertToDatabaseColumn(Block attribute) {
|
||||
if (attribute == null) {
|
||||
return null;
|
||||
}
|
||||
return attribute.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block convertToEntityAttribute(Integer dbData) {
|
||||
if (dbData == null) {
|
||||
return null;
|
||||
}
|
||||
return Block.fromId(dbData);
|
||||
}
|
||||
|
||||
}
|
||||
25
src/main/java/love/sola/netsupport/enums/ISPConverter.java
Normal file
25
src/main/java/love/sola/netsupport/enums/ISPConverter.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package love.sola.netsupport.enums;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class ISPConverter implements AttributeConverter<ISP, Integer> {
|
||||
|
||||
@Override
|
||||
public Integer convertToDatabaseColumn(ISP attribute) {
|
||||
if (attribute == null) {
|
||||
return null;
|
||||
}
|
||||
return attribute.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISP convertToEntityAttribute(Integer dbData) {
|
||||
if (dbData == null) {
|
||||
return null;
|
||||
}
|
||||
return ISP.fromId(dbData);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user