Embeded měrné jednotky (new MUnitEmb) mají nyní ID inicializované na 0.

Převod DB nastaví NULL hodnoty ID na 0, takže načtení přes hibernate
vytvoří neNULLový objekt MUnitEmb.

closes #185
Verze_1.0
František Přibyl 10 years ago
parent 8e33bb8ef7
commit a0447318e6

@ -30,7 +30,7 @@ import java.util.Map;
public class Constants {
public final static long DB_VERSION = 1;
public final static long DB_VERSION = 2;
public final static String DEF_ADMIN = "admin";
public final static String DEF_ADMIN_PASSWD = "admin";

@ -20,6 +20,9 @@ public class MUnitEmb
public MUnitEmb()
{
// Embeddable object is loaded by hibernate like NULL, if all properties
// are NULL. So, we set ID.
this.id = 0;
}
public MUnitEmb(MUnit munit)

@ -64,9 +64,13 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
if (Constants.DB_VERSION > dbVersion)
{
SQLQuery sq = null;
String sql = "";
if (dbVersion < 1)
{
List<Str2Str> tables = new ArrayList<Str2Str>();
tables.add(new Str2Str("address", "DESCRIPTION"));
tables.add(new Str2Str("building", "DESCRIPTION"));
tables.add(new Str2Str("material", "DESCRIPTION"));
@ -91,9 +95,6 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
tables.add(new Str2Str("trip_bill_items", "BACK_VEHICLE_DESCRIPTION"));
tables.add(new Str2Str("trip_bill_items", "VEHICLE_DESCRIPTION"));
SQLQuery sq = null;
String sql = "";
for (Str2Str item : tables)
{
sql = "ALTER TABLE " + item.getKey() + " MODIFY " + item.getValue() + " VARCHAR(" + String.valueOf(Constants.LEN_DESCRIPTION) + ")";
@ -102,6 +103,22 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
}
}
if (dbVersion < 2)
{
List<String> tables = new ArrayList<String>();
tables.add("material");
tables.add("order_item");
tables.add("requirement_items");
for (String item : tables)
{
sql = "UPDATE " + item + " SET MUNIT_ID = 0 WHERE (MUNIT_ID Is NULL) ";
sq = this.dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
}
}
this.updateDatabaseVersion();
}
}

@ -183,7 +183,14 @@ public class RequirementForm extends FormViewModel<Requirement>
if (isMaterial)
{
Material materialItem = (Material) selected;
item.setMunit(materialItem.getMunit());
MUnitEmb unit = materialItem.getMunit();
// if (unit == null)
// {
// unit = new MUnitEmb();
// }
item.setMunit(unit);
}
this.setSelectedItem(item);

Loading…
Cancel
Save