[JBoss Seam] - Multiple validation contexts
by gonzalad
Hello,
I have a strange application (requirement) which implies different validation rules depending on the execution context.
Here's the explanation :
- the application will be used by 4/5 different organizations. Those will manipulate the same entities (same database) but each one of those organizations have some business specificities [1].
- the UI will be different for each of these clients.
[1] For instance field1 of EntityA will be optional for organization 1, whereas it will be mandatory for organization 2 (and min length = 2...).
We're going for the following decomposition :
1 - there will be a common module containing all the common rules. This will be a jar module with entities/dao/services.
2 - we'll create a web module for each organization.
Specific business rules will be coded in actions or in specific services located in each web module.
So here's my question :
- where can I put validation logic (using Hibernate validation tags) ?
For common rules, it will be on jpa entities in the common module.
But for specific rules ?
I see only 2 solutions :
1 - use plain Jsf validators for the specific validation rules on the jsf pages.
2 - use or create a contextual validation module (see http://forum.hibernate.org/viewtopic.php?t=974761, also seen this kind of validation in the roadmap of Spring modules), and just put the context in the thread local (using some sort of filter for instance).
Do you have some ideas on thos approaches ? Is there sthing better I didn't thought about ? (surely...)
Thanks in advance !
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081126#4081126
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081126
18 years, 7 months
[Persistence, JBoss/CMP, Hibernate, Database] - update to hibernate 3.2.5 causes query exception
by sgollery
I'm trying to move from hibernate 3.2.1 to 3.2.5, but I've run into a query that used to work and now throws this exception:
Illegal attempt to dereference collection [patient0_.patient_key.studiesSubmittedTo] with element property reference [submittedDate]...
The query code looks like this:
Date cutoffDate = new Date((new Date()).getTime() - weeksToMillis(pendingPatientCutoff));
String qStr = "select distinct p from Patient p where p.studiesSubmittedTo.submittedDate >= :date and p.studiesSubmittedTo.status != 'Randomized' and p.studiesSubmittedTo.status != 'NotRandomized' and p.studiesSubmittedTo.status != 'Billed' order by p.lastName";
Query q = session.createQuery(qStr);
q.setParameter("date", cutoffDate);
List patients = (List)q.list();
The mapping for studiesSubmittedTo defines a composite-element in the Patient mapping. The relevant part of the mapping file is this:
| <hibernate-mapping package="model">
| <class
| name="Patient"
| table="Patient">
| <id name="id" column="patient_key" type="long">
| <generator class="native" />
| </id>
|
| <set name="studiesSubmittedTo" table="Patient_Studies"
| cascade="all">
| <key column="patient_key"/>
| <composite-element class="StudyPatientAssociation">
| <parent name="patient"/>
|
| <property name="submittedDate" type="date"/>
|
| <property name="status">
| <type name="userTypes.GenericEnumUserType">
| <param name="enumClass">model.StudyPatientAssociation$Status</param>
| </type>
| </property>
|
| </composite-element>
| </set>
| </hibernate-mapping>
|
|
This query is supposed to return only those patients that have at least one element in their studiesSubmittedTo collection whose date is at or after some other date. The element also has to not have a certain list of values for the status, but I think that's not part of the problem.
So: why did this query work in 3.2.1 but not in 3.2.5, and is there some other query that would accomplish the same thing and be acceptable to 3.2.5?
Thanks in advance.
Steven Gollery
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081114#4081114
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081114
18 years, 7 months
[JBoss Seam] - Re: best practice for handling double-click during a long-ru
by eghchang
thanks norman and amitev for your replies.
norman, when double-clicking i can see (using firebug) that two requests are being sent to the application server before any response is received. furthermore, i don't see any errors in the server log that would suggest a double insert/optimistic locking. yet i still get the same "the conversation ended, timed out, or was processing another request" error message. in this particular case, i'm posting back to the same page in the context of a long-running conversation (simple "save" functonality that does not navigate away).
i had been setting no-cache http headers to force refresh of pages (via a JSF phase listener), but i disabled these headers thinking that perhaps they are complicating things. the one other thing that's odd is that i can see that even with single-click requests, action methods are being called twice. however, this has been the case for a while and we haven't had any other problems (e.g. optimistic locking) as a result. we are using keep-alive connections, but i wouldn't think that should have any impact.
just as a sanity check, if i am seeing multiple requests from the browser before any response, would you expect the error message i'm seeing?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081110#4081110
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081110
18 years, 7 months