IllegalArgumentException: id to load is required for loading В чем сдесь проблема?
Как только программа заходит в метод loginClient выкидывает IllegalArgumentException: id to load is required for loading. Cуть метода получить ввод юзера из html формы, найти юзера по юзернайм в базе и сверить введенные и данные в базе.
@PostMapping("/login")
public String loginClient(@ModelAttribute("input") Input input) throws Exception {
String page = "";
userInput = input.getPostUsername();
Client existingClient = service.getClient(userInput);
if((input.getPostUsername().equals(existingClient.getUsername())&
(input.getPostPassword().equals(existingClient.getPassword())))){
page = "Auth";
SpotifyAPI newApi = new SpotifyAPI();
newApi.startServer(8081);
}
else{
page = "index";
}
return page;
<form method="post" th:action="@{/login}" th:object="${input}" class="login">
<p>
<label th:for="postUsername">Username: </label>
<input type="text" th:name="postUsername" id="postUsername"/>
</p>
<p>
<label th:for="postPassword">Password: </label>
<input type="text" th:name="postPassword" id="postPassword"/>
</p>
java.lang.IllegalArgumentException: id to load is required for loading
org.hibernate.event.spi.LoadEvent.<init>(LoadEvent.java:93)
org.hibernate.event.spi.LoadEvent.<init>(LoadEvent.java:63)
org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2920)
org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.lambda$load$1(SessionImpl.java:2904)
org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.perform(SessionImpl.java:2860)
org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2904)
org.hibernate.internal.SessionImpl.get(SessionImpl.java:1097)
spotify.repository.ClientDAOImpl.getCustomer(ClientDAOImpl.java:58)
spotify.service.ClientServiceImpl.getClient(ClientServiceImpl.java:41)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:567)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
com.sun.proxy.$Proxy46.getClient(Unknown Source)
spotify.controller.AppControl.loginClient(AppControl.java:31)
ClientServiceImpl class:
@Override
@Transactional
public Client getClient(String username) {
return clientDAO.getCustomer(username);
}
DAOimpl
@Override
public Client getCustomer(String username) {
// get the current hibernate session
Session currentSession = sessionFactory.getCurrentSession();
// now retrieve/read from database using the primary key
return currentSession.get(Client.class, username);
}