views:

21

answers:

0

I'm trying to do some validation of complex constraints on Hibernate entities in a JBoss JEE system. For that purpose, I need my validator (whether it be an actual JSR303 validator or just an EntityListener for PrePersist/PreUpdate/PreRemove) to have access to my DAO beans. Much perusal of JSR303 stuff doesn't give me any indication that this is possible, and injecting a listener with @EntityListener does not cause injections on the listener in turn - it is apparently just created with newInstance.

Details on the constraints:
In our model, Sites contain Installations. Sites have SiteTypes and Installations have InstallationTypes. Each SiteType has a list of which InstallationTypes are legal within it. The SiteType and InstallationType entities do not know what Sites resp. Installations use them, but there is a DAO method that will give this information.

When a SiteType is changed, we want to check that all Sites of that type only have Installations that are of legal types. For this, we need the DAO, and thus some way to inject the relevant DAO bean. Is there any way to get this injection? Any nice way?

Thanks in advance,
-Lars