Hi all,
i have a problem with one Thread that is running all time. This thread looks one field in a table and wait for this field changes. Problem is that object class is loaded at Start up but when I change field value it doen't start. With debug i saw that the value is the same it doen't refresh. HBM.XML are:
tCentros.hbm.xml
Code:
<hibernate-mapping package="bbdd.modelos">
<class name="tCentros"
table="centros" lazy="true">
<!-- Common id property. -->
<id name="Id_Centro"
type="string"
column="id_centro"
unsaved-value="0">
<generator class="native"/>
</id>
<!-- A versioned entity. -->
<property name="Nombre"
type="string"
column="nombre"
not-null="true"/>
<property name="Direccion"
type="string"
column="direccion"
not-null="true"/>
<property name="Telefono"
type="string"
column="telefono"
not-null="true"/>
<!-- Name of the item is immutable. -->
<property name="Apertura"
type="date"
column="apertura"
not-null="true"/>
<!-- Limit item description to 4000 characters, Oracle. -->
<property name="Id_Seq"
type="int"
column="id_sec"
not-null="true"/>
<one-to-one name="Servidor" class="tServidores" constrained="true"/>
</class>
</hibernate-mapping>
tServidores.hbm.xmlCode:
<hibernate-mapping package="bbdd.modelos">
<class name="tServidores"
table="servidores" lazy="true">
<!-- Common id property. -->
<id name="Id_Centro"
type="string"
column="id_centro"
unsaved-value="0">
<generator class="native"/>
</id>
<!-- A versioned entity. -->
<property name="Servidor1"
type="string"
column="servidor1"
not-null="true"/>
<property name="Servidor2"
type="string"
column="servidor2"
not-null="true"/>
<property name="Login"
type="string"
column="login"
not-null="true"/>
<!-- Name of the item is immutable. -->
<property name="Password"
type="string"
column="password"
not-null="true"/>
<!-- Limit item description to 4000 characters, Oracle. -->
<property name="IFX_BBDD"
type="string"
column="ifx_bbdd"
not-null="true"/>
<property name="Pass_BT"
type="string"
column="pass_bt"
not-null="true"/>
<property name="IFX_Server"
type="string"
column="ifx_server"
not-null="true"/>
<property name="IFX_Port"
type="int"
column="ifx_port"
not-null="true"/>
<property name="Refresh"
type="int"
column="refresh"
not-null="true"/>
<property name="Num_Tienda"
type="int"
column="num_tienda"
not-null="true"/>
<property name="IFX_Login"
type="string"
column="ifx_user"
not-null="true"/>
<property name="IFX_Pass"
type="string"
column="ifx_pass"
not-null="true"/>
<property name="Ruta_Winepts"
type="string"
column="ruta_winepts"
not-null="true"/>
<property name="IFX_Conector"
type="string"
column="ifx_connector"
not-null="true"/>
<property name="Winepts_Name"
type="string"
column="winepts_name"
not-null="true"/>
<property name="Winepts_Exe"
type="int"
column="winepts_exe"
not-null="true"/>
</class>
</hibernate-mapping>
Thread CodeCode:
public class ListadosWinepts extends Thread {
private Collection centros = null;
/** Creates a new instance of ListadosWinepts */
public ListadosWinepts(String sFecha) {
super();
generaListados(sFecha);
}
private void generaListados(String sFecha){
[b]this.centros = new CentrosDAO().findAll();[/b] --> Get all Centers with its owns tServidores class
for (Iterator it=this.centros.iterator();it.hasNext();)
{
tCentros centro = (tCentros) it.next();
if (centro.getServidor().getWinepts_Exe()==1) {
if (leerRealizado(centro.getId_Centro())==1) {
if (sFecha.equals(""))
{
new oWinEpts(centro.getServidor().getRuta_Winepts(), centro.getId_Centro(),false);
guardaRealizado (centro.getId_Centro());
}
else
new oWinEpts(centro.getServidor().getRuta_Winepts(), centro.getId_Centro(), sFecha,false);
}
}
}
if (leerRealizado("0000")==1) {
if (sFecha.equals("")) {
new oWinEpts("/mnt/winepts/central", "central",true);
guardaRealizado ("0000");
}
else
new oWinEpts("/mnt/winepts/central", "central",sFecha,true);
}
this.centros=null;
}
private void guardaRealizado (String sCentro) {
tServidores savewinepts = new ServidoresDAO().getServerById(sCentro, false);
[b]savewinepts.setWinepts_Exe(0);[/b] --> when done. Changes value
new ServidoresDAO().save(savewinepts);
new ServidoresDAO().commit();
}
private int leerRealizado(String sCentro) {
tServidores savewinepts = new ServidoresDAO().getServerById(sCentro, false);
return savewinepts.getWinepts_Exe();
}
}
Changes in field are made by a linux cron. I think is a problem with synchronize. All Object classes are Serializables.
Thanks a lot.