Problem solved!
What I need to do is this:
Within my class section of the mapping file:
Code:
<many-to-one name="customer" column="user_number" not-null="true"
foreign-key="forkey" />
<filter name="customerFilter" condition=":customerId = user_number"/>
And then my filter code is:
Code:
<filter-def name="customerFilter">
<filter-param name="customerId" type="int"/>
</filter-def>
In some ways it is less elegant because I'm manually having to use the ID number of customer objects, but it is very workable and does exactly what I want. So I guess that is the solution to using filters in cases where the filtering is aon a many-to-one, instead of on a property. At least it's clear how it's working.
Now I have things set up so that a customer logs in and there is a servlet filter that secures his access to the site, and that servlet filter creates the Hibernate session and the session is
also filtered so that a customer can only see his stuff.
This is awesome and the sanest most secure way to develop a web app.
Constrasting this to PHP where there are no filters (either at the DB layer or the web page layer) and there are SQL injection attacks all over the place.