[Persistence, JBoss/CMP, Hibernate, Database] - Writing Hibernate validator
by waheed.murad
I want to have my own Hibernate annotaion validator...... named NotEmpty a problem is that when after form submition the only initialize() method is called. isValid() method does not executes......
below is the code and Thanks in advance for help......
------------- Annotation descriptor -------------------
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.hibernate.validator.ValidatorClass;
@ValidatorClass(value=NotEmptyValidator.class)
@Target(value={ElementType.METHOD,ElementType.FIELD})
@Retention(value=RetentionPolicy.RUNTIME)
@Documented
public @interface NotEmpty {
String message() default "Field cannot be empty";
}
------------- Annotation validator -------------------
import org.hibernate.validator.PropertyConstraint;
import org.hibernate.validator.Validator;
import java.io.Serializable;
public class NotEmptyValidator implements Validator, PropertyConstraint, Serializable {
public boolean isValid(Object value) {
System.out.println(" is Valid method called...");
..............
..............
return false;
}
public void initialize(NotEmpty parameters) {
System.out.println(" Initialize method called...");
}
public void apply(org.hibernate.mapping.Property property){
System.out.println(" Apply method called...");
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995049#3995049
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995049
19 years, 4 months
[JBoss Seam] - Re: Basic Seam questions
by lightbulb432
1) I'm probably not asking that question correctly...lemme try again. How does Seam know that there's a new conversation, such that it has to increment or change the conversation ID to a new number?
What confuses me is that at any time there's a cid request parameter value...what indicates to Seam that it's time to start a new conversation (apart from hitting another @Begin method)?
I keep hearing that Seam solves the "back button issue", whatever that is...does Seam do this through conversations?
2) Regarding the persist(), it actually is for a brand new entity, which is why I seemed so amazed. Does this happen because of the fact that the entity has been "created" through its use as a backing bean (but I don't see how it became managed by the persistence context).
By the way, can I output everything that's being managed in a given persistence context? (I don't mean EntityManager's contains())
3) Is there any simple way to get writes going to one DB and reads going to its replicated DB (or balance between that and the original DB in addition)?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995040#3995040
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995040
19 years, 4 months
[Messaging, JMS & JBossMQ] - MDB and connection to a remote queue with transaction
by mclu
Like
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=91589
I have the same or equal problem.
I have 2 JBoss Servers(A and B). Both 4.0.5 with Messaging 1.0.1 GA
On A I have an MDB listen on a local queue
inside the onmessage it should get the message and send a Result to a Queue on Server B.
Inside my MDB on A I create a connection using B´s JNDI and look for XAConnectionFactory.
I open the session like this:
session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
But after the onMessage returns the Message is still not in the DB on B.
If I do it like
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
it works.
It works also, if I use TRUE and commit the session explicitly with session.comit(); But if then an exception on A occurs I have the Message still in A and already in B.
Question:
How can I span my JTA Transaction of Server A to include the send to B?
Now some config stuff follows:
My MDB Config:
<message-driven>
| <ejb-name>SyncRequestSenderMDB</ejb-name>
| <ejb-class>com.XXX.send.SyncRequestSenderMDB</ejb-class>
| <transaction-type>Container</transaction-type>
| <message-driven-destination>
| <destination-type>javax.jms.Queue</destination-type>
| </message-driven-destination>
| </message-driven>
| </enterprise-beans>
| <assembly-descriptor>
| <container-transaction>
| <method>
| <ejb-name>SyncRequestSenderMDB</ejb-name>
| <method-name>*</method-name>
| </method>
| <trans-attribute>Required</trans-attribute>
| </container-transaction>
| </assembly-descriptor>
My remote send call:
| Connection conn = null;
| MessageProducer sender = null;
| try {
|
| conn = getConnection();
| boolean transacted = true;
| session = conn
| .createSession(transacted, Session.AUTO_ACKNOWLEDGE);
|
| sender = session.createProducer(sendQueue);
|
| TextMessage tm = session.createTextMessage(syncMessage.getMessageAsString());
|
| sender.send(tm);
| Logger.debug(this, "Message sent to IM Server");
| // with this it will be send
| // session.commit();
|
| } catch (JMSException e) {
| throw new RuntimeException(
| "Problems sending Sync Message to IM Server Queue.", e);
| } finally {
| if (sender != null)
| try {
| sender.close();
| } catch (Exception ignore) {
| }
| if (session != null)
| try {
| session.close();
| } catch (Exception ignore) {
| }
| if (conn != null)
| try {
| conn.close();
| } catch (Exception ignore) {
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995038#3995038
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995038
19 years, 4 months