links for 2011-03-05

6 03 2011
  • There's an Entity Class "A". Class A might have children of the same type "A". Also "A" should hold it's parent if it is a child.
    Is this possible? If so how should I map the relations in the Entity class? ["A" has an id column.]

    @Entity
    public class A implements Serializable {
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    @ManyToOne private A parent;
    @OneToMany(mappedBy="parent")
    private Collection<A> children;

    // Code…
    }

    Here's a rough main() method that persists three such entities:

    public static void main(String[] args) {

    EntityManager em = … // from EntityManagerFactory, injection, etc.

    em.getTransaction().begin();

    A parent = new A();
    A son = new A();
    A daughter = new A();

    son.setParent(parent);
    daughter.setParent(parent);
    parent.setChildren(Arrays.asList(son, daughter));

    em.persist(parent);
    em.persist(son);
    em.persist(daughter);

    em.getTransaction().commit();
    }

  • Hello, from time to time (that's the worst about this bug😉 ) I'm getting an: org.jboss.seam.ConcurrentRequestTimeoutException: Concurrent call to conversation.

    After a long search😉, The bug was of course on our side. We were ending a conversation programatically, by calling Conversation.endBeforeRedirect(). However, there was no redirect, so the conversation lock wasn't released.

    I changed it to be Conversation.end() and then Conversation.leave(), which causes the conversation to end, release the lock and start a new one. And so far no exceptions🙂

    Adam Warski


Acciones

Information

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s




A %d blogueros les gusta esto: