当点击api将数据输入数据库时,我在表数据类型方面存在一些问题。下面是我的代码,总是返回“错误:运算符不存在:字符变化=整数”,此错误引用“ queueServiceImpl.class中的Poliklinik对象。有人可以帮助我解决吗?
Poliklinik.class
@Data
@Entity
@Table(name = "poliklinik")
public class Poliklinik {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "_poliklinik_generator")
@SequenceGenerator(name = "_poliklinik_generator", sequenceName = "poliklinik_serial", allocationSize = 1, initialValue = 1)
@Column(name = "id")
private long id;
@Column(name = "code")
@NotNull
private String code;
@JoinColumn(name = "schedule")
@ManyToOne
private TypeOfSchedule scheduleCode;
@JoinColumn(name = "doctor")
@ManyToOne
@Type(type = "long")
private DokterData doctorName;
@JoinColumn(name = "specialization")
@ManyToOne
private TypeOfSpecialization specialization;
@Column(name = "kuota")
private int kuota;
}
DokterData.class
@Data
@Entity
@Table(name = "dokter_data")
public class DokterData {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "_dokter_generator")
@SequenceGenerator(name = "_dokter_generator", sequenceName = "serial", allocationSize = 1, initialValue = 1)
@Column(name = "id")
private long id;
@JoinColumn(name = "account")
@NotNull
@OneToOne
private User account;
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@JoinColumn(name = "specialization")
@ManyToOne
private TypeOfSpecialization specialization;
@Column(name = "address")
private String address;
}
queueServiceImpl.class
@Override
public BaseResponse addQueue(AddQueueRequest req) {
if (req.getPoliklinik() == null || req.getPoliklinik().equals("")){
return baseResponse(ConstantUtil.STATUS_INCOMPLETE_DATA,
"poliklinik code", null);
}
if (req.getPaymentType().equals("") || req.getPaymentType() == null){
return baseResponse(ConstantUtil.STATUS_INCOMPLETE_DATA,
"payment type", null);
}
if (!req.getPaymentType().equals("CASH") || !req.getPaymentType().equals("OTHER")){
if (req.getPaymentNumber().equals("") || req.getPaymentNumber() == null){
return baseResponse(ConstantUtil.STATUS_INCOMPLETE_DATA,
"payment number", null);
}
}
User user = userRepository.findUserById(req.getAccount());
TypeOfSpecialization specialization = typeOfSpecialization.findTypeOfSpecializationByCode(req.getPoliklinik());
TypeOfSchedule schedule = scheduleRepository.findTypeOfScheduleByName("SHIFT_1");
logger.info("schedule info = " + schedule.getName() );
Poliklinik timeSchedule = poliklinikRepository.findPoliklinikByCode(req.getPoliklinik());
// Poliklinik timeSchedule = poliklinikRepository.findPoliklinikByCodeAndScheduleCode(req.getPoliklinik(), schedule);
logger.info("poliklinik data = " + timeSchedule.getCode() + " and " + timeSchedule.getId());
// Poliklinik timeSchedule = poliklinikRepository.findBycodeAndShift(req.getPoliklinik(), String.valueOf(schedule.getId()));
Poliklinik poliklinik = new Poliklinik();
Payment payment = paymentRepository.findPaymentByCode(req.getPaymentType());
Queue queue = new Queue();
queue.setAccount(user);
queue.setDate(new Date());
queue.setPoliklinik(timeSchedule);
queue.setPaymentNumber(req.getPaymentNumber());
queue.setPayment(payment);
queue.setRowStatus(false);
int kuota = poliklinik.getKuota();
logger.info("kuota poliklinik " + kuota);
if (kuota != 0) {
queueRepository.save(queue);
//String startTime = timeSchedule.getSchedule().getStartTime();
//String endTime = timeSchedule.getSchedule().getEndTime();
poliklinik.setKuota(kuota - 1);
poliklinikRepository.save(poliklinik);
AddQueueResponse response = new AddQueueResponse();
response.setMessage("Anda berhasil mendaftar silahkan datang ke rumah sakit untuk menunggu antrian");
//response.setRangeTime( startTime + " - " + endTime);
//response.setSchedule(poliklinik.getScheduleCode());
return baseResponse(0,"Pendaftaran antrian", response);
} else {
return baseResponse(2, "poliklinik penuh silahkan daftar ke shift selanjutnya", null);
}
}
日志
Hibernate:
select
dokterdata0_.id as id1_14_0_,
dokterdata0_.account as account5_14_0_,
dokterdata0_.address as address2_14_0_,
dokterdata0_.first_name as first_na3_14_0_,
dokterdata0_.last_name as last_nam4_14_0_,
dokterdata0_.specialization as speciali6_14_0_,
user1_.id as id1_9_1_,
user1_.account_expired as account_2_9_1_,
user1_.account_locked as account_3_9_1_,
user1_.created_date as created_4_9_1_,
user1_.password as password5_9_1_,
user1_.password_count as password6_9_1_,
user1_.session_id as session_7_9_1_,
user1_.token as token8_9_1_,
user1_.user_id as user_id9_9_1_,
user1_.user_role as user_ro10_9_1_,
user1_.user_status as user_st11_9_1_,
role2_.id as id1_7_2_,
role2_.code as code2_7_2_,
role2_.role as role3_7_2_,
userstatus3_.id as id1_10_3_,
userstatus3_.code as code2_10_3_,
userstatus3_.status as status3_10_3_,
typeofspec4_.id as id1_21_4_,
typeofspec4_.code as code2_21_4_,
typeofspec4_.specialization as speciali3_21_4_
from
dokter_data dokterdata0_
inner join
_user user1_
on dokterdata0_.account=user1_.id
left outer join
_role role2_
on user1_.user_role=role2_.id
left outer join
_user_status userstatus3_
on user1_.user_status=userstatus3_.id
left outer join
type_of_specialization typeofspec4_
on dokterdata0_.specialization=typeofspec4_.id
where
dokterdata0_.id=?
2019-05-22 13:56:31 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [BIGINT] - [8]
2019-05-22 13:56:31 WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 42883
2019-05-22 13:56:31 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ERROR: operator does not exist: character varying = integer
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Position: 1073
2019-05-22 13:56:32 INFO o.h.e.i.DefaultLoadEventListener - HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not extract ResultSet
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:69)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.getResultSet(AbstractLoadPlanBasedLoader.java:419)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeQueryStatement(AbstractLoadPlanBasedLoader.java:191)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86)
at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:188)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4269)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:511)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:481)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:222)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:124)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1257)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1140)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:682)
at org.hibernate.type.EntityType.resolve(EntityType.java:464)
at org.hibernate.type.ManyToOneType.resolve(ManyToOneType.java:239)
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:172)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1151)
at org.hibernate.loader.Loader.processResultSet(Loader.java:1010)
at org.hibernate.loader.Loader.doQuery(Loader.java:948)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:340)
at org.hibernate.loader.Loader.doList(Loader.java:2689)
at org.hibernate.loader.Loader.doList(Loader.java:2672)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2506)
at org.hibernate.loader.Loader.list(Loader.java:2501)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:504)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:395)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:220)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1508)
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1537)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1505)
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1553)
at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:109)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:214)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:91)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:136)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:125)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:135)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy106.findPoliklinikByCode(Unknown Source)
at id.developer.rs_thamrin.service.impl.QueueServiceImpl.addQueue(QueueServiceImpl.java:67)
at id.developer.rs_thamrin.controller.QueueController.userDetail(QueueController.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)