我搜索了许多有关此问题的答案,但没有任何结果适合我。这是一个Spring MVC Maven项目。请帮忙。
这是我的用户类别:
@Entity
@Table(name = "USER", catalog = "srvcs")
public class User implements java.io.Serializable {
private Integer userId;
private Group group;
private String name;
private String address;
private String email;
private String tel;
private String username;
private String role;
private String status;
private Date createdDate;
private Set<Object> objectsForUpdatedBy = new HashSet<Object>(0);
private Set<Folder> foldersForCreatedBy = new HashSet<Folder>(0);
private Set<Object> objectsForCreatedBy = new HashSet<Object>(0);
private Set<Folder> foldersForOwnerId = new HashSet<Folder>(0);
private Set<Object> objectsForOwnerId = new HashSet<Object>(0);
private Set<Log> logs = new HashSet<Log>(0);
private Set<Folder> foldersForUpdatedBy = new HashSet<Folder>(0);
public User() {
}
public User(String name, String email, String tel, String username, String role, String status, Date createdDate) {
this.name = name;
this.email = email;
this.tel = tel;
this.username = username;
this.role = role;
this.status = status;
this.createdDate = createdDate;
}
public User(Group group, String name, String address, String email, String tel, String username, String role,
String status, Date createdDate, Set<Object> objectsForUpdatedBy, Set<Folder> foldersForCreatedBy,
Set<Object> objectsForCreatedBy, Set<Folder> foldersForOwnerId, Set<Object> objectsForOwnerId,
Set<Log> logs, Set<Folder> foldersForUpdatedBy) {
this.group = group;
this.name = name;
this.address = address;
this.email = email;
this.tel = tel;
this.username = username;
this.role = role;
this.status = status;
this.createdDate = createdDate;
this.objectsForUpdatedBy = objectsForUpdatedBy;
this.foldersForCreatedBy = foldersForCreatedBy;
this.objectsForCreatedBy = objectsForCreatedBy;
this.foldersForOwnerId = foldersForOwnerId;
this.objectsForOwnerId = objectsForOwnerId;
this.logs = logs;
this.foldersForUpdatedBy = foldersForUpdatedBy;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "user_id", unique = true, nullable = false)
public Integer getUserId() {
return this.userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "group_id")
public Group getGroup() {
return this.group;
}
public void setGroup(Group group) {
this.group = group;
}
@Column(name = "name", nullable = false, length = 100)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "address", length = 500)
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
@Column(name = "email", nullable = false, length = 100)
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name = "tel", nullable = false, length = 20)
public String getTel() {
return this.tel;
}
public void setTel(String tel) {
this.tel = tel;
}
@Column(name = "username", nullable = false, length = 50)
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "role", nullable = false, length = 45)
public String getRole() {
return this.role;
}
public void setRole(String role) {
this.role = role;
}
@Column(name = "status", nullable = false, length = 45)
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_date", nullable = false, length = 19)
public Date getCreatedDate() {
return this.createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userByUpdatedBy")
public Set<Object> getObjectsForUpdatedBy() {
return this.objectsForUpdatedBy;
}
public void setObjectsForUpdatedBy(Set<Object> objectsForUpdatedBy) {
this.objectsForUpdatedBy = objectsForUpdatedBy;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userByCreatedBy")
public Set<Folder> getFoldersForCreatedBy() {
return this.foldersForCreatedBy;
}
public void setFoldersForCreatedBy(Set<Folder> foldersForCreatedBy) {
this.foldersForCreatedBy = foldersForCreatedBy;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userByCreatedBy")
public Set<Object> getObjectsForCreatedBy() {
return this.objectsForCreatedBy;
}
public void setObjectsForCreatedBy(Set<Object> objectsForCreatedBy) {
this.objectsForCreatedBy = objectsForCreatedBy;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userByOwnerId")
public Set<Folder> getFoldersForOwnerId() {
return this.foldersForOwnerId;
}
public void setFoldersForOwnerId(Set<Folder> foldersForOwnerId) {
this.foldersForOwnerId = foldersForOwnerId;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userByOwnerId")
public Set<Object> getObjectsForOwnerId() {
return this.objectsForOwnerId;
}
public void setObjectsForOwnerId(Set<Object> objectsForOwnerId) {
this.objectsForOwnerId = objectsForOwnerId;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<Log> getLogs() {
return this.logs;
}
public void setLogs(Set<Log> logs) {
this.logs = logs;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userByUpdatedBy")
public Set<Folder> getFoldersForUpdatedBy() {
return this.foldersForUpdatedBy;
}
public void setFoldersForUpdatedBy(Set<Folder> foldersForUpdatedBy) {
this.foldersForUpdatedBy = foldersForUpdatedBy;
}
}
我的小组班:
@Entity
@Table(name = "GROUP", catalog = "srvcs")
public class Group implements java.io.Serializable {
private Integer groupId;
private String groupName;
private String status;
private Date createdDate;
private int createdBy;
private Set<Folder> folders = new HashSet<Folder>(0);
private Set<Object> objects = new HashSet<Object>(0);
private Set<User> users = new HashSet<User>(0);
public Group() {
}
public Group(String groupName, String status, Date createdDate, int createdBy) {
this.groupName = groupName;
this.status = status;
this.createdDate = createdDate;
this.createdBy = createdBy;
}
public Group(String groupName, String status, Date createdDate, int createdBy, Set<Folder> folders,
Set<Object> objects, Set<User> users) {
this.groupName = groupName;
this.status = status;
this.createdDate = createdDate;
this.createdBy = createdBy;
this.folders = folders;
this.objects = objects;
this.users = users;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "group_id", unique = true, nullable = false)
public Integer getGroupId() {
return this.groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
@Column(name = "group_name", nullable = false, length = 100)
public String getGroupName() {
return this.groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
@Column(name = "status", nullable = false, length = 45)
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_date", nullable = false, length = 19)
public Date getCreatedDate() {
return this.createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
@Column(name = "created_by", nullable = false)
public int getCreatedBy() {
return this.createdBy;
}
public void setCreatedBy(int createdBy) {
this.createdBy = createdBy;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "group")
public Set<Folder> getFolders() {
return this.folders;
}
public void setFolders(Set<Folder> folders) {
this.folders = folders;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "group")
public Set<Object> getObjects() {
return this.objects;
}
public void setObjects(Set<Object> objects) {
this.objects = objects;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "group")
public Set<User> getUsers() {
return this.users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
}
以上两个实体类都是使用Eclipse IDE自动生成的。 DLL如下所示:
用户表:
CREATE TABLE `USER` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`address` varchar(500) DEFAULT NULL,
`email` varchar(100) NOT NULL,
`tel` varchar(20) NOT NULL,
`username` varchar(50) NOT NULL,
`role` varchar(45) NOT NULL,
`status` varchar(45) NOT NULL,
`group_id` int(11) DEFAULT NULL,
`created_date` datetime NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_id_UNIQUE` (`user_id`),
KEY `fk_user_group_idx` (`group_id`),
CONSTRAINT `fk_user_group` FOREIGN KEY (`group_id`) REFERENCES `GROUP` (`group_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4
组表:
CREATE TABLE `GROUP` (
`group_id` int(11) NOT NULL AUTO_INCREMENT,
`group_name` varchar(100) NOT NULL,
`status` varchar(45) NOT NULL,
`created_date` datetime NOT NULL,
`created_by` int(11) NOT NULL,
PRIMARY KEY (`group_id`),
UNIQUE KEY `group_id_UNIQUE` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4
我在此DAO方法中遇到错误:
@Override
@Transactional("transactionManager")
public List<User> getUsersOfGroup(Integer groupId) {
String hql = "from User usr where usr.group = :group";
@SuppressWarnings("unchecked")
TypedQuery<User> query = sessionFactory.getCurrentSession().createQuery(hql);
query.setParameter("group", groupId);
List<User> userList = query.getResultList();
if(userList != null && !userList.isEmpty()){
return userList;
}
return null;
}
完整的错误日志:
16:27:57,423 ERROR [org.hibernate.property.access.spi.GetterMethodImpl] (default task-2) HHH000122: IllegalArgumentException in class: com.dms.model.Group, getter method of property: groupId
16:27:57,430 javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.dms.model.Group.groupId
16:27:57,434 at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
16:27:57,434 at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
16:27:57,434 at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1515)
16:27:57,435 at org.hibernate.query.Query.getResultList(Query.java:146)
16:27:57,435 at com.dms.dao.AdminDaoImpl.getUsersOfGroup(AdminDaoImpl.java:43)
16:27:57,435 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:27:57,436 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
16:27:57,438 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:27:57,438 at java.lang.reflect.Method.invoke(Method.java:498)
16:27:57,439 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338)
16:27:57,439 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
16:27:57,439 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
16:27:57,440 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
16:27:57,440 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
16:27:57,441 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
16:27:57,441 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
16:27:57,441 at com.sun.proxy.$Proxy85.getUsersOfGroup(Unknown Source)
16:27:57,441 at com.dms.service.AdminServiceImpl.lambda$1(AdminServiceImpl.java:284)
16:27:57,442 at java.util.ArrayList.forEach(ArrayList.java:1255)
16:27:57,442 at com.dms.service.AdminServiceImpl.getJsonStringForGroupList(AdminServiceImpl.java:276)
16:27:57,442 at com.dms.view.AdminViewImpl.getGroupListView(AdminViewImpl.java:55)
16:27:57,442 at com.dms.controller.AdminController.listGroupsValidDMSValidToken(AdminController.java:144)
16:27:57,442 at com.dms.controller.AdminController$$FastClassBySpringCGLIB$$2c30026d.invoke(<generated>)
16:27:57,443 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
16:27:57,443 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
16:27:57,443 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
16:27:57,443 at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
16:27:57,455 at com.dms.aspect.DMSValidation.validateToken(DMSValidation.java:130)
16:27:57,455 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:27:57,455 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
16:27:57,455 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:27:57,455 at java.lang.reflect.Method.invoke(Method.java:498)
16:27:57,456 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:643)
16:27:57,456 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:632)
16:27:57,456 at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
16:27:57,456 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
16:27:57,456 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
16:27:57,457 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
16:27:57,457 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
16:27:57,457 at com.dms.controller.AdminController$$EnhancerBySpringCGLIB$$37b10a5.listGroupsValidDMSValidToken(<generated>)
16:27:57,458 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:27:57,458 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
16:27:57,458 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:27:57,458 at java.lang.reflect.Method.invoke(Method.java:498)
16:27:57,458 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
16:27:57,458 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
16:27:57,459 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
16:27:57,459 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:871)
16:27:57,459 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:777)
16:27:57,459 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
16:27:57,459 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
16:27:57,460 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
16:27:57,460 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
16:27:57,460 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
16:27:57,460 at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
16:27:57,460 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
16:27:57,460 at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
16:27:57,460 at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
16:27:57,461 at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
16:27:57,461 at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
16:27:57,461 at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
16:27:57,461 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
16:27:57,461 at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
16:27:57,461 at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
16:27:57,461 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
16:27:57,462 at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
16:27:57,462 at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
16:27:57,462 at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
16:27:57,462 at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
16:27:57,462 at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
16:27:57,462 at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
16:27:57,463 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
16:27:57,463 at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
16:27:57,463 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
16:27:57,463 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
16:27:57,463 at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
16:27:57,463 at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
16:27:57,463 at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
16:27:57,464 at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
16:27:57,464 at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
16:27:57,464 at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
16:27:57,464 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
16:27:57,464 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
16:27:57,464 at java.lang.Thread.run(Thread.java:748)
16:27:57,465 Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.dms.model.Group.groupId
16:27:57,465 at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:65)
16:27:57,465 at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:224)
16:27:57,465 at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4896)
16:27:57,465 at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4596)
16:27:57,466 at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:226)
16:27:57,466 at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:276)
16:27:57,466 at org.hibernate.type.EntityType.getIdentifier(EntityType.java:495)
16:27:57,466 at org.hibernate.type.EntityType.nullSafeSet(EntityType.java:288)
16:27:57,466 at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:53)
16:27:57,466 at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:645)
16:27:57,466 at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2000)
16:27:57,467 at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1914)
16:27:57,467 at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1892)
16:27:57,467 at org.hibernate.loader.Loader.doQuery(Loader.java:937)
16:27:57,467 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:340)
16:27:57,467 at org.hibernate.loader.Loader.doList(Loader.java:2689)
16:27:57,467 at org.hibernate.loader.Loader.doList(Loader.java:2672)
16:27:57,467 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2506)
16:27:57,468 at org.hibernate.loader.Loader.list(Loader.java:2501)
16:27:57,468 at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:504)
16:27:57,468 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:395)
16:27:57,468 at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:221)
16:27:57,468 at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1508)
16:27:57,468 at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1538)
16:27:57,469 at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1506)
16:27:57,469 ... 81 more
16:27:57,469 Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
16:27:57,470 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:27:57,470 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
16:27:57,470 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:27:57,470 at java.lang.reflect.Method.invoke(Method.java:498)
16:27:57,470 at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:42)
16:27:57,470 ... 105 more
我正在使用Java8 / Spring5 / Hibernate5
感谢您的帮助!
答案 0 :(得分:1)
我想你是说:
from User usr where usr.group.groupId = :group
因为您传递的是groupId
而不是Group
对象