Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COMaybe. The user object is not a JPA managed object, it is JDBC managed. There are 2 places when the user object has the dealer object set to it. One is in the spring UserDetailsContextMapper, and the other is in a struts action. When the dealer logs in, their dealer object is set into the permissioned user so that it doesn't have to be retrieved, and so that it can be used to limit queries to just their data. When a system admin logs in, the sysadmin person selects a dealer to manage from a list, and I set the dealer object to the user so I can reuse artifacts. See Addl. code above
      singulars
    2. COOk, so the LazyInitializationException only happens when the dealer object is set into the PermissionedUser object in the struts action, not when the dealer is set into the PermissionedUser in the UserDetailsContextMapper. So, this is starting to look like the right answer. Why would the object be detached in the struts object? Is it because my struts method is get* and that is a read-only transaction in the applicationContext.xml file?
      singulars
    3. COOk, the problem is related somehow to transactions, so I guess I don't understand this as well as I wish I did. In my original code, the problem only showed up in the struts action. By using the struts Prepareable interceptor and the paramsPrepareParamsStack, I was retrieving the dealer in the prepare method, and setting the dealer to the user in a different method. When I moved the method call to set the dealer to the user object in the same transactional method, the LazyInitializationException disappears. Refactored working code posted above.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload