I just realised that you could use an xml descriptor file for describing the bean. I could put the correct xml in jboss.xml and ejb-jar.xml. But then I encounter another problem. Currently I am also using EJB 2.1 beans and the ejb-jar.xml has the following line:
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
So if I were to change the file for EJB 3.0 entity bean, it would get recognised as a EJB 2.1 bean which I don't want.
Long story short, is there a way of having 2 descriptor files: one for EJB 2.1 and another one for EJB 3.0?
In answer to your first question, why not just use the @Column annotation, e.g.,
The ejb3 persistence spec has more details.
This is not what I aiming to do. The annotation:
just prevents inserting & updating of the field. I was looking for a more general solution which prevents for example, the following type of query:
SQL statement "SELECT 1 FROM ONLY "public"."name" x WHERE "id" = $1 FOR UPDATE OF x"
I think I need to be give specific imformation to how I arrived at the problem.
I have a few tables in postgres which I am accessing using entity beans. Some of these tables contain basic information like user names, password etc. The other tables have columns which have id's from these tables as foreign keys.
When the JBoss server is running, I am getting the following error in the jboss log:
2006-01-27 16:00:05,914 ERROR [org.hibernate.util.JDBCExceptionReporter] ERROR: deadlock detected 2006-01-27 16:00:05,914 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
and in the database I am getting the error:
CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."name" x WHERE "id" = $1 FOR UPDATE OF x" ERROR: deadlock detected DETAIL: Process 3177 waits for ShareLock on transaction 9349151; blocked by process 3175. Process 3175 waits for ShareLock on transaction 9349149; blocked by process 3177.
These transactions succedd if I send them again (as one expects).
The problem is that the transactions which are throwing this error are not updating the name table. I just want to use a simple select query instead of a "select _____ for update of __" query.
If I remove the foreign key constraint for name, I do not get these errors.
This led me to thinking that having read-only entity beans for basic objects like name might solve the problem.