On 16.8.21 14:45, Thiago H. de Paula Figueiredo wrote:
- Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This
required some changes in tapestry-hibernate due to some
non-backward-compatible changes between these 2 Hibernate versions.
I'm experiencing some issue where session.createQuery always returns a
null in the constructor of a SessionState object, after moving to 5.7.3.
Otherwise everything works and is a welcome upgrade.
Are there any differences in how and when Tapestry creates the hibernate
session and how this behaves after this upgrade?
More details:
I have a @SessionState UserInfo in each page where the authenticated
user details are needed.
The UserInfo class constructor calls a PersonManager service to find the
logged-in user details.
Authentication is external so it is not part of the problem. Apereo CAS,
over all paths of the server, so that request.remoteUser contains the
loggedin user name.
In this personManager i have @Inject Session session and i have
session.createQuery.
Now the strange change in behaviour is that after upgrade to 5.7.3, all
calls to session.CreateQuery always return null when personManager is
called in the UserInfo constructor. Whatever query I use, it returns a
null. As if the session is not working. But the session is not null, the
session object status is OK and session object connection status is ok.
If I call the personManager directly from a page (setupRender or
property getter) everything works fine.
Probably something is not written as it supposed to be and I need to
refactor. Maybe we are not supposed to fill-in the UserInfo session
state object details during its construction, but later. But this piece
of code is more than 10 years old and has survived over all the Tapestry
5.x.x upgrades in the meanwhile and worked fine until now.
UserInfo example:
https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/util/UserInfo.java
PersonImpl example (nothing special here):
public class PersonDaoImpl implements PersonDao {
@Inject private Logger logger;
@Inject private Session session;
@Override
public List<Person> getAllPersons() {
try {
return session.createQuery("from Person order by
lastName").list();
} catch (Exception e) {
return null;
}
}
@Override
public Person getPersonByUsername(String username) {
try {
return (Person) (session
.createQuery("from Person where userName=:param")
.setParameter("param", username).setReadOnly(true)
.setCacheable(true).uniqueResult());
} catch (Exception e) {
return null;
}
}
In case it matters, there is a ComponentRequestFilter to protect access
to pages depending on the user role, implemented like this:
https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/services/AccessController.java
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org