Edit: After some more debugging, I have changed the description of this question
In Hibernate 5.6 with Spring 5.3 I have very weird issue. I want to insert a new user role into a table. i can see the insert-statement in console log but the data never appears in the table.
The table:
CREATE TABLE public.ums_t_user_role (
fk_role_id int8 NOT NULL,
fk_user_id varchar(500) NOT NULL,
CONSTRAINT user_role_combine_key PRIMARY KEY (fk_role_id, fk_user_id)
);
The .hbm.xml mapping:
<hibernate-mapping>
<class name="com.myapp.ums.business.impl.UmsUserRoleVOImpl" table="ums_t_user_role"
proxy="com.myapp.ums.common.business.UmsUserRoleVO">
<composite-id>
<key-property name="userName" type="java.lang.String" column="fk_user_id"/>
<key-property name="roleName" type="java.lang.Long" column="fk_role_id"/>
</composite-id>
</class>
</hibernate-mapping>
The business logic:
UmsUserRoleVO userRole = new UmsUserRoleVOImpl();
userRole.setUserName(userVO.getLoginId());
userRole.setRoleName(Long.valueOf(role));
this.userRoleDAO.save(userRole);
The userRoleDAO:
@Override
public final void save(final ENTITY instance) {
getHibernateTemplate().saveOrUpdate(instance);
getHibernateTemplate().flush();
}
When I hit the userRole.DAO method, I can see that the select + insert statements are generated in console. But the data is missing in the table. Any idea what the issue could be here?
Hibernate:
13:05:33,583 INFO [stdout] (default task-7) select
13:05:33,583 INFO [stdout] (default task-7) umsuserrol_.fk_user_id,
13:05:33,583 INFO [stdout] (default task-7) umsuserrol_.fk_role_id
13:05:33,583 INFO [stdout] (default task-7) from
13:05:33,583 INFO [stdout] (default task-7) ums_t_user_role umsuserrol_
13:05:33,583 INFO [stdout] (default task-7) where
13:05:33,583 INFO [stdout] (default task-7) umsuserrol_.fk_user_id=?
13:05:33,583 INFO [stdout] (default task-7) and umsuserrol_.fk_role_id=?
13:05:33,583 INFO [stdout] (default task-7) Hibernate:
13:05:33,583 INFO [stdout] (default task-7) insert
13:05:33,583 INFO [stdout] (default task-7) into
13:05:33,583 INFO [stdout] (default task-7) ums_t_user_role
13:05:33,583 INFO [stdout] (default task-7) (fk_user_id, fk_role_id)
13:05:33,583 INFO [stdout] (default task-7) values
13:05:33,583 INFO [stdout] (default task-7) (?, ?)