r3826 - in branches/4.0.1/src/main/java/fr/ifremer/isisfish: types/hibernate util
Author: echatellier Date: 2013-11-02 10:31:48 +0100 (Sat, 02 Nov 2013) New Revision: 3826 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/3826 Log: Comment non used code non compilable since hibernate 4.2 Modified: branches/4.0.1/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java branches/4.0.1/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java Modified: branches/4.0.1/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java =================================================================== --- branches/4.0.1/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java 2013-10-31 22:54:54 UTC (rev 3825) +++ branches/4.0.1/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java 2013-11-02 09:31:48 UTC (rev 3826) @@ -69,9 +69,6 @@ */ private static final Log log = LogFactory.getLog(MatrixType.class); - public MatrixType() { - } - public boolean isMutable() { return true; } @@ -92,7 +89,7 @@ if(str.startsWith("[") && str.endsWith("]")) { str = str.substring(1, str.length()-1); // remove [ and ] } - String [] dimAsString = StringUtil.split(str, ","); + String [] dimAsString = StringUtil.split(str, ","); int[] result = new int[dimAsString.length]; int i = 0; for (String dim : dimAsString) { @@ -285,8 +282,8 @@ private static final Type[] hibernateTypes = { StandardBasicTypes.STRING, //name (String) StandardBasicTypes.STRING, //dim (int[]) - StandardBasicTypes.CLOB, //dimNames (String[]) - StandardBasicTypes.CLOB, //semantics (List[]) + StandardBasicTypes.CLOB, //dimNames (String[]) + StandardBasicTypes.CLOB, //semantics (List[]) StandardBasicTypes.CLOB //data (List<List<...>>) }; Modified: branches/4.0.1/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java =================================================================== --- branches/4.0.1/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java 2013-10-31 22:54:54 UTC (rev 3825) +++ branches/4.0.1/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java 2013-11-02 09:31:48 UTC (rev 3826) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric + * Copyright (C) 2006 - 2013 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -32,15 +32,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.HibernateException; -import org.hibernate.engine.QueryParameters; -import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.spi.QueryParameters; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.type.StandardBasicTypes; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaId; - /** * Classe utilise pour convertir une chaine en un objet TopiaEntity. * @@ -50,15 +49,12 @@ */ public class TopiaEntityConverter implements Converter { - /** - * Logger for this class - */ - private static final Log log = LogFactory - .getLog(TopiaEntityConverter.class); + /** Logger for this class. */ + private static final Log log = LogFactory.getLog(TopiaEntityConverter.class); protected TopiaContext context = null; protected SessionImplementor session = null; - + public TopiaEntityConverter(TopiaContext context) { this.context = context; } @@ -67,15 +63,13 @@ this.session = session; } - /* (non-Javadoc) - * @see org.apache.commons.beanutils.Converter#convert(java.lang.Class, java.lang.Object) - */ + @Override public Object convert(Class type, Object value) { Object result = null; if (value instanceof TopiaEntity) { result = value; - } else if (value instanceof String){ - result = getTopiaEntity((String)value); + } else if (value instanceof String) { + result = getTopiaEntity((String) value); } else { throw new ConversionException("Can't convert '" + value + "' to " + type.getName()); } @@ -88,7 +82,8 @@ try { TopiaContext tx = context.beginTransaction(); result = tx.findByTopiaId(topiaId); - // FIXME when after tx.closeContext we can continu to load object, call it here + // FIXME when after tx.closeContext we can continu to load + // object, call it here tx.commitTransaction(); tx.closeContext(); } catch (TopiaException eee) { @@ -99,19 +94,21 @@ } else if (session != null) { QueryParameters params = new QueryParameters(StandardBasicTypes.STRING, topiaId); String entityClass = TopiaId.getClassNameAsString(topiaId); - + try { + /* Non compilable code since hibernate 4.2, but not a real, not usefull boolean mustCommit = false; if (!session.getJDBCContext().getTransaction().isActive()) { mustCommit = true; session.getJDBCContext().getTransaction().begin(); - } + }*/ String hql = "from " + entityClass + " where topiaId=?"; List results = session.list(hql, params); - if (mustCommit) { + + /*if (mustCommit) { session.getJDBCContext().getTransaction().commit(); - } - result = (TopiaEntity)results.get(0); + }*/ + result = (TopiaEntity) results.get(0); } catch (HibernateException eee) { if (log.isDebugEnabled()) { log.debug("Can't find TopiaEntity: " + topiaId, eee);
participants (1)
-
echatellier@users.forge.codelutin.com