// Cria sessao
SessaoUsuario sessaoUsuario = new SessaoUsuario();
sessaoUsuario.setData(new Date());
- sessaoUsuario.setUsuario(caso.getUsuario());
+ sessaoUsuario.setCaso(caso);
em.persist(sessaoUsuario);
// Logo inicio do caso
private Date data;
@ManyToOne
- @JoinColumn(nullable=false, name="usu_id")
- private Usuario usuario;
+ @JoinColumn(nullable=false, name="caso_id")
+ private Caso caso;
public Date getData() {
return data;
this.data = data;
}
- public Usuario getUsuario() {
- return usuario;
- }
-
- public void setUsuario(Usuario usuario) {
- this.usuario = usuario;
- }
-
public Long getId() {
return id;
}
public String toString() {
return "org.ufcspa.simdecs.entities.SessaoUsuario[ id=" + id + " ]";
}
-
+
+ public Caso getCaso() {
+ return caso;
+ }
+
+ public void setCaso(Caso caso) {
+ this.caso = caso;
+ }
}
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.util;
+
+import javax.persistence.EntityManager;
+
+/**
+ *
+ * @author maroni
+ */
+public class PopulaDados {
+
+ private static EntityManager em;
+
+ static {
+ em = DbUtil.getInstance().getEntityManager();
+ }
+
+ public static void insereDadosIniciais() {
+ em.getTransaction().begin();
+
+ em.createNativeQuery("DELETE FROM USUARIO;").executeUpdate();
+ em.createNativeQuery("INSERT INTO USUARIO (id, login, nome, senha) VALUES (nextval('SQ_USUARIO'), 'simdecs', 'simdecs', 'simdecs');").executeUpdate();
+ em.createNativeQuery("DELETE FROM TIPO_EVENTO_LOG;").executeUpdate();
+ em.createNativeQuery("INSERT INTO TIPO_EVENTO_LOG (id, nome) VALUES ('INICIO_CASO', 'InĂcio do Caso');").executeUpdate();
+
+ em.getTransaction().commit();
+ }
+
+}