diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/daos/IntegrationEntityDAO.java b/libreplan-business/src/main/java/org/libreplan/business/common/daos/IntegrationEntityDAO.java index fe794405e..02dc456b8 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/daos/IntegrationEntityDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/daos/IntegrationEntityDAO.java @@ -60,6 +60,7 @@ public class IntegrationEntityDAO @SuppressWarnings("unchecked") @Override + @Transactional(readOnly = true) public E findByCode(String code) throws InstanceNotFoundException { if (StringUtils.isBlank(code)) { diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderElementDAO.java b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderElementDAO.java index c0060e9c6..ceae2321c 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderElementDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderElementDAO.java @@ -202,6 +202,7 @@ public class OrderElementDAO extends IntegrationEntityDAO @SuppressWarnings("unchecked") @Override + @Transactional(readOnly = true) public OrderElement findByCode(String code) throws InstanceNotFoundException { diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ExpenseSheetConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ExpenseSheetConverter.java index c89c49db3..79ae9f756 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ExpenseSheetConverter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ExpenseSheetConverter.java @@ -45,13 +45,13 @@ public class ExpenseSheetConverter implements IConverter { @Override public String asString(ExpenseSheet entity) { - return entity.getId().toString(); + return entity.getCode(); } @Override public ExpenseSheet asObject(String stringRepresentation) { try { - return expenseSheetDAO.find(Long.parseLong(stringRepresentation)); + return expenseSheetDAO.findByCode(stringRepresentation); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderConverter.java index 09f19b1f6..b7dd48297 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderConverter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderConverter.java @@ -45,7 +45,7 @@ public class OrderConverter implements IConverter { @Transactional(readOnly = true) public Order asObject(String stringRepresentation) { try { - return orderDAO.find(Long.parseLong(stringRepresentation)); + return orderDAO.findByCode(stringRepresentation); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } @@ -53,7 +53,7 @@ public class OrderConverter implements IConverter { @Override public String asString(Order entity) { - return entity.getId() + ""; + return entity.getCode(); } @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderElementConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderElementConverter.java index 5f30b2fb8..6a5ffcf7f 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderElementConverter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/OrderElementConverter.java @@ -42,7 +42,7 @@ public class OrderElementConverter implements IConverter { @Override public OrderElement asObject(String stringRepresentation) { try { - return orderElementDAO.find(Long.parseLong(stringRepresentation)); + return orderElementDAO.findByCode(stringRepresentation); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } @@ -50,7 +50,7 @@ public class OrderElementConverter implements IConverter { @Override public String asString(OrderElement entity) { - return entity.getId() + ""; + return entity.getCode(); } @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ResourceConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ResourceConverter.java index 4f9016741..1f0c74540 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ResourceConverter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/ResourceConverter.java @@ -44,9 +44,8 @@ public class ResourceConverter implements IConverter { @Override @Transactional(readOnly = true) public Resource asObject(String stringRepresentation) { - long id = Long.parseLong(stringRepresentation); try { - return resourceDAO.find(id); + return resourceDAO.findByCode(stringRepresentation); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } @@ -54,7 +53,7 @@ public class ResourceConverter implements IConverter { @Override public String asString(Resource entity) { - return entity.getId() + ""; + return entity.getCode(); } @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportConverter.java index e0a3e87f4..2de7e7a01 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportConverter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportConverter.java @@ -46,13 +46,13 @@ public class WorkReportConverter implements IConverter { @Override public String asString(WorkReport entity) { - return entity.getId() + ""; + return entity.getCode(); } @Override public WorkReport asObject(String stringRepresentation) { try { - return workReportDAO.find(Long.parseLong(stringRepresentation)); + return workReportDAO.findByCode(stringRepresentation); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportTypeConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportTypeConverter.java index 01a7a8a15..d4c712324 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportTypeConverter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/WorkReportTypeConverter.java @@ -40,9 +40,9 @@ public class WorkReportTypeConverter implements IConverter { @Override @Transactional(readOnly = true) public WorkReportType asObject(String stringRepresentation) { - long id = Long.parseLong(stringRepresentation); try { - WorkReportType workReportType = workReportTypeDAO.find(id); + WorkReportType workReportType = workReportTypeDAO + .findByCode(stringRepresentation); return workReportType; } catch (InstanceNotFoundException e) { throw new RuntimeException(e); @@ -51,7 +51,7 @@ public class WorkReportTypeConverter implements IConverter { @Override public String asString(WorkReportType entity) { - return entity.getId().toString(); + return entity.getCode(); } @Override