Advertisement
Guest User

hibernate patch

a guest
Mar 4th, 2013
1,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.89 KB | None | 0 0
  1. From f8d97ea71200895dd8d7b2a9dddac7f998ec8b7b Mon Sep 17 00:00:00 2001
  2. From: Petr Stastny <p.stastny@gmx.de>
  3. Date: Mon, 4 Mar 2013 15:51:06 +0100
  4. Subject: [PATCH] Update Hibernate Plugin for Hibernate 4.x
  5.  
  6. ---
  7. sql12/fw/pom.xml | 13 ++
  8. .../squirrel_sql/fw/dialects/TeiidDialect.java | 172 +++++++++++---------
  9. .../WikiTableConfigurationFactoryTest.java | 1 -
  10. sql12/installer/pom.xml | 6 +-
  11. .../server/HibernateServerConnectionImpl.java | 61 ++++---
  12. 5 files changed, 152 insertions(+), 101 deletions(-)
  13.  
  14. diff --git a/sql12/fw/pom.xml b/sql12/fw/pom.xml
  15. index 2a7fdf6..a57656d 100644
  16. --- a/sql12/fw/pom.xml
  17. +++ b/sql12/fw/pom.xml
  18. @@ -114,6 +114,18 @@
  19. <version>1.6.1</version>
  20. </dependency>
  21. <dependency>
  22. + <groupId>org.hibernate</groupId>
  23. + <artifactId>hibernate-core</artifactId>
  24. + <version>4.1.9.Final</version>
  25. + <exclusions>
  26. + <exclusion>
  27. + <groupId>javax.transaction</groupId>
  28. + <artifactId>jta</artifactId>
  29. + </exclusion>
  30. + </exclusions>
  31. + </dependency>
  32. + <!--
  33. + <dependency>
  34. <groupId>org.hibernate</groupId>
  35. <artifactId>hibernate-annotations</artifactId>
  36. <version>${hibernate-annotations-version}</version>
  37. @@ -140,6 +152,7 @@
  38.  
  39. </exclusions>
  40. </dependency>
  41. + -->
  42. <dependency>
  43. <groupId>net.sourceforge.jexcelapi</groupId>
  44. <artifactId>jxl</artifactId>
  45. diff --git a/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/TeiidDialect.java b/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/TeiidDialect.java
  46. index 0bf20aa..2b8e6ec 100644
  47. --- a/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/TeiidDialect.java
  48. +++ b/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/TeiidDialect.java
  49. @@ -27,12 +27,26 @@ import java.sql.ResultSet;
  50. import java.sql.SQLException;
  51. import java.sql.Types;
  52.  
  53. -import org.hibernate.Hibernate;
  54. import org.hibernate.LockMode;
  55. import org.hibernate.dialect.Dialect;
  56. import org.hibernate.dialect.function.NoArgSQLFunction;
  57. import org.hibernate.dialect.function.StandardSQLFunction;
  58. import org.hibernate.dialect.function.VarArgsSQLFunction;
  59. +import org.hibernate.type.BigDecimalType;
  60. +import org.hibernate.type.BigIntegerType;
  61. +import org.hibernate.type.BlobType;
  62. +import org.hibernate.type.CharacterType;
  63. +import org.hibernate.type.ClobType;
  64. +import org.hibernate.type.DateType;
  65. +import org.hibernate.type.DoubleType;
  66. +import org.hibernate.type.FloatType;
  67. +import org.hibernate.type.IntegerType;
  68. +import org.hibernate.type.LongType;
  69. +import org.hibernate.type.ObjectType;
  70. +
  71. +import org.hibernate.type.StringType;
  72. +import org.hibernate.type.TimeType;
  73. +import org.hibernate.type.TimestampType;
  74.  
  75. /**
  76. * This class was temporarily re-packaged and will remain so until it deployed to
  77. @@ -67,94 +81,94 @@ public class TeiidDialect extends Dialect {
  78. registerColumnType(Types.CLOB, "clob"); //$NON-NLS-1$
  79. registerColumnType(Types.JAVA_OBJECT, "object"); //$NON-NLS-1$
  80.  
  81. - registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  82. - registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  83. - registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  84. - registerFunction("atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  85. + registerFunction("acos", new StandardSQLFunction("acos", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  86. + registerFunction("asin", new StandardSQLFunction("asin", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  87. + registerFunction("atan", new StandardSQLFunction("atan", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  88. + registerFunction("atan2", new StandardSQLFunction("atan2", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  89. registerFunction("ceil", new StandardSQLFunction("ceiling")); //$NON-NLS-1$ //$NON-NLS-2$
  90. - registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  91. - registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  92. - registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  93. - registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  94. + registerFunction("cos", new StandardSQLFunction("cos", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  95. + registerFunction("cot", new StandardSQLFunction("cot", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  96. + registerFunction("degrees", new StandardSQLFunction("degrees", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  97. + registerFunction("exp", new StandardSQLFunction("exp", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  98. registerFunction("floor", new StandardSQLFunction("floor")); //$NON-NLS-1$ //$NON-NLS-2$
  99. - registerFunction("formatbigdecimal", new StandardSQLFunction("formatbigdecimal", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  100. - registerFunction("formatbiginteger", new StandardSQLFunction("formatbiginteger", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  101. - registerFunction("formatdouble", new StandardSQLFunction("formatdouble", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  102. - registerFunction("formatfloat", new StandardSQLFunction("formatfloat", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  103. - registerFunction("formatinteger", new StandardSQLFunction("formatinteger", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  104. - registerFunction("formatlong", new StandardSQLFunction("formatlong", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  105. - registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  106. + registerFunction("formatbigdecimal", new StandardSQLFunction("formatbigdecimal", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  107. + registerFunction("formatbiginteger", new StandardSQLFunction("formatbiginteger", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  108. + registerFunction("formatdouble", new StandardSQLFunction("formatdouble", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  109. + registerFunction("formatfloat", new StandardSQLFunction("formatfloat", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  110. + registerFunction("formatinteger", new StandardSQLFunction("formatinteger", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  111. + registerFunction("formatlong", new StandardSQLFunction("formatlong", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  112. + registerFunction("log", new StandardSQLFunction("log", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  113. registerFunction("mod", new StandardSQLFunction("mod")); //$NON-NLS-1$ //$NON-NLS-2$
  114. - registerFunction("parsebigdecimal", new StandardSQLFunction("parsebigdecimal", Hibernate.BIG_DECIMAL)); //$NON-NLS-1$ //$NON-NLS-2$
  115. - registerFunction("parsebiginteger", new StandardSQLFunction("parsebiginteger", Hibernate.BIG_INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  116. - registerFunction("parsedouble", new StandardSQLFunction("parsedouble", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  117. - registerFunction("parsefloat", new StandardSQLFunction("parsefloat", Hibernate.FLOAT)); //$NON-NLS-1$ //$NON-NLS-2$
  118. - registerFunction("parseinteger", new StandardSQLFunction("parseinteger", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  119. - registerFunction("parselong", new StandardSQLFunction("parselong", Hibernate.LONG)); //$NON-NLS-1$ //$NON-NLS-2$
  120. - registerFunction("pi", new StandardSQLFunction("pi", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  121. - registerFunction("power", new StandardSQLFunction("power", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  122. - registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  123. + registerFunction("parsebigdecimal", new StandardSQLFunction("parsebigdecimal", BigDecimalType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  124. + registerFunction("parsebiginteger", new StandardSQLFunction("parsebiginteger", BigIntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  125. + registerFunction("parsedouble", new StandardSQLFunction("parsedouble", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  126. + registerFunction("parsefloat", new StandardSQLFunction("parsefloat", FloatType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  127. + registerFunction("parseinteger", new StandardSQLFunction("parseinteger", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  128. + registerFunction("parselong", new StandardSQLFunction("parselong", LongType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  129. + registerFunction("pi", new StandardSQLFunction("pi", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  130. + registerFunction("power", new StandardSQLFunction("power", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  131. + registerFunction("radians", new StandardSQLFunction("radians", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  132. registerFunction("round", new StandardSQLFunction("round")); //$NON-NLS-1$ //$NON-NLS-2$
  133. - registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  134. - registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  135. - registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
  136. -
  137. - registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  138. - registerFunction("chr", new StandardSQLFunction("chr", Hibernate.CHARACTER)); //$NON-NLS-1$ //$NON-NLS-2$
  139. - registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER)); //$NON-NLS-1$ //$NON-NLS-2$
  140. - registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  141. - registerFunction("initcap", new StandardSQLFunction("initcap", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  142. - registerFunction("insert", new StandardSQLFunction("insert", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  143. - registerFunction("lcase", new StandardSQLFunction("lcase", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  144. - registerFunction("left", new StandardSQLFunction("left", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  145. - registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  146. - registerFunction("lpad", new StandardSQLFunction("lpad", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  147. - registerFunction("ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  148. - registerFunction("repeat", new StandardSQLFunction("repeat", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  149. - registerFunction("replace", new StandardSQLFunction("replace", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  150. - registerFunction("right", new StandardSQLFunction("right", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  151. - registerFunction("rpad", new StandardSQLFunction("rpad", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  152. - registerFunction("rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  153. - registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  154. - registerFunction("translate", new StandardSQLFunction("translate", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  155. - registerFunction("ucase", new StandardSQLFunction("ucase", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  156. -
  157. - registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE)); //$NON-NLS-1$ //$NON-NLS-2$
  158. - registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME)); //$NON-NLS-1$ //$NON-NLS-2$
  159. - registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
  160. - registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  161. - registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  162. - registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  163. - registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  164. - registerFunction("formatdate", new StandardSQLFunction("formatdate", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  165. - registerFunction("formattime", new StandardSQLFunction("formattime", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  166. - registerFunction("formattimestamp", new StandardSQLFunction("formattimestamp", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  167. - registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  168. - registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  169. - registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  170. - registerFunction("parsedate", new StandardSQLFunction("parsedate", Hibernate.DATE)); //$NON-NLS-1$ //$NON-NLS-2$
  171. - registerFunction("parsetime", new StandardSQLFunction("parsetime", Hibernate.TIME)); //$NON-NLS-1$ //$NON-NLS-2$
  172. - registerFunction("parsetimestamp", new StandardSQLFunction("parsetimestamp", Hibernate.TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
  173. - registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  174. - registerFunction("timestampcreate", new StandardSQLFunction("timestampcreate", Hibernate.TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
  175. + registerFunction("sign", new StandardSQLFunction("sign", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  176. + registerFunction("sin", new StandardSQLFunction("sin", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  177. + registerFunction("tan", new StandardSQLFunction("tan", DoubleType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  178. +
  179. + registerFunction("ascii", new StandardSQLFunction("ascii", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  180. + registerFunction("chr", new StandardSQLFunction("chr", CharacterType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  181. + registerFunction("char", new StandardSQLFunction("char", CharacterType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  182. + registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  183. + registerFunction("initcap", new StandardSQLFunction("initcap", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  184. + registerFunction("insert", new StandardSQLFunction("insert", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  185. + registerFunction("lcase", new StandardSQLFunction("lcase", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  186. + registerFunction("left", new StandardSQLFunction("left", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  187. + registerFunction("locate", new StandardSQLFunction("locate", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  188. + registerFunction("lpad", new StandardSQLFunction("lpad", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  189. + registerFunction("ltrim", new StandardSQLFunction("ltrim", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  190. + registerFunction("repeat", new StandardSQLFunction("repeat", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  191. + registerFunction("replace", new StandardSQLFunction("replace", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  192. + registerFunction("right", new StandardSQLFunction("right", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  193. + registerFunction("rpad", new StandardSQLFunction("rpad", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  194. + registerFunction("rtrim", new StandardSQLFunction("rtrim", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  195. + registerFunction("substring", new StandardSQLFunction("substring", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  196. + registerFunction("translate", new StandardSQLFunction("translate", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  197. + registerFunction("ucase", new StandardSQLFunction("ucase", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  198. +
  199. + registerFunction("curdate", new NoArgSQLFunction("curdate", DateType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  200. + registerFunction("curtime", new NoArgSQLFunction("curtime", TimeType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  201. + registerFunction("now", new NoArgSQLFunction("now", TimestampType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  202. + registerFunction("dayname", new StandardSQLFunction("dayname", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  203. + registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  204. + registerFunction("dayofweek", new StandardSQLFunction("dayofweek", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  205. + registerFunction("dayofyear", new StandardSQLFunction("dayofyear", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  206. + registerFunction("formatdate", new StandardSQLFunction("formatdate", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  207. + registerFunction("formattime", new StandardSQLFunction("formattime", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  208. + registerFunction("formattimestamp", new StandardSQLFunction("formattimestamp", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  209. + registerFunction("hour", new StandardSQLFunction("hour", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  210. + registerFunction("minute", new StandardSQLFunction("minute", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  211. + registerFunction("monthname", new StandardSQLFunction("monthname", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  212. + registerFunction("parsedate", new StandardSQLFunction("parsedate", DateType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  213. + registerFunction("parsetime", new StandardSQLFunction("parsetime", TimeType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  214. + registerFunction("parsetimestamp", new StandardSQLFunction("parsetimestamp", TimestampType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  215. + registerFunction("second", new StandardSQLFunction("second", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  216. + registerFunction("timestampcreate", new StandardSQLFunction("timestampcreate", TimestampType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  217. registerFunction("timestampAdd", new StandardSQLFunction("timestampAdd")); //$NON-NLS-1$ //$NON-NLS-2$
  218. - registerFunction("timestampDiff", new StandardSQLFunction("timestampDiff", Hibernate.LONG)); //$NON-NLS-1$ //$NON-NLS-2$
  219. - registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  220. - registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  221. - registerFunction("modifytimezone", new StandardSQLFunction("modifytimezone", Hibernate.TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
  222. + registerFunction("timestampDiff", new StandardSQLFunction("timestampDiff", LongType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  223. + registerFunction("week", new StandardSQLFunction("week", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  224. + registerFunction("year", new StandardSQLFunction("year", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  225. + registerFunction("modifytimezone", new StandardSQLFunction("modifytimezone", TimestampType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  226.  
  227. registerFunction("convert", new StandardSQLFunction("convert")); //$NON-NLS-1$ //$NON-NLS-2$
  228.  
  229. - registerFunction("to_bytes", new StandardSQLFunction("to_bytes", Hibernate.BLOB)); //$NON-NLS-1$ //$NON-NLS-2$
  230. - registerFunction("to_chars", new StandardSQLFunction("to_chars", Hibernate.CLOB)); //$NON-NLS-1$ //$NON-NLS-2$
  231. - registerFunction("from_unittime", new StandardSQLFunction("from_unittime", Hibernate.TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
  232. - registerFunction("session_id", new StandardSQLFunction("session_id", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  233. + registerFunction("to_bytes", new StandardSQLFunction("to_bytes", BlobType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  234. + registerFunction("to_chars", new StandardSQLFunction("to_chars", ClobType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  235. + registerFunction("from_unittime", new StandardSQLFunction("from_unittime",TimestampType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  236. + registerFunction("session_id", new StandardSQLFunction("session_id", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  237.  
  238. - registerFunction("uuid", new StandardSQLFunction("uuid", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  239. - registerFunction("unescape", new StandardSQLFunction("unescape", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
  240. + registerFunction("uuid", new StandardSQLFunction("uuid", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  241. + registerFunction("unescape", new StandardSQLFunction("unescape", StringType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  242.  
  243. - registerFunction("array_get", new StandardSQLFunction("uuid", Hibernate.OBJECT)); //$NON-NLS-1$ //$NON-NLS-2$
  244. - registerFunction("array_length", new StandardSQLFunction("unescape", Hibernate.INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
  245. + registerFunction("array_get", new StandardSQLFunction("uuid", ObjectType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  246. + registerFunction("array_length", new StandardSQLFunction("unescape", IntegerType.INSTANCE)); //$NON-NLS-1$ //$NON-NLS-2$
  247. }
  248.  
  249. public boolean dropConstraints() {
  250. diff --git a/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationFactoryTest.java b/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationFactoryTest.java
  251. index fbdaf8f..446fa24 100644
  252. --- a/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationFactoryTest.java
  253. +++ b/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationFactoryTest.java
  254. @@ -26,7 +26,6 @@ import java.util.List;
  255.  
  256. import net.sourceforge.squirrel_sql.BaseSQuirreLJUnit4TestCase;
  257.  
  258. -import org.hibernate.validator.AssertTrue;
  259. import org.junit.Before;
  260. import org.junit.Test;
  261.  
  262. diff --git a/sql12/installer/pom.xml b/sql12/installer/pom.xml
  263. index cc466f0..eeff727 100644
  264. --- a/sql12/installer/pom.xml
  265. +++ b/sql12/installer/pom.xml
  266. @@ -107,10 +107,14 @@
  267. <includedArtifact>commons-logging:commons-logging</includedArtifact>
  268. <includedArtifact>com.jgoodies:forms</includedArtifact>
  269. <includedArtifact>net.sf.squirrel-sql:fw</includedArtifact>
  270. +<!--
  271. <includedArtifact>org.hibernate:hibernate-annotations</includedArtifact>
  272. <includedArtifact>org.hibernate:hibernate-commons-annotations</includedArtifact>
  273. <includedArtifact>org.hibernate:hibernate-entitymanager</includedArtifact>
  274. - <includedArtifact>org.hibernate:hibernate</includedArtifact>
  275. +-->
  276. + <includedArtifact>org.jboss.logging:jboss-logging</includedArtifact>
  277. + <includedArtifact>org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec</includedArtifact>
  278. + <includedArtifact>org.hibernate:hibernate-core</includedArtifact>
  279. <includedArtifact>net.sourceforge.jexcelapi:jxl</includedArtifact>
  280. <includedArtifact>log4j:log4j</includedArtifact>
  281. <includedArtifact>be.cyberelf.nanoxml:nanoxml</includedArtifact>
  282. diff --git a/sql12/plugins/hibernate/src/main/java/net/sourceforge/squirrel_sql/plugins/hibernate/server/HibernateServerConnectionImpl.java b/sql12/plugins/hibernate/src/main/java/net/sourceforge/squirrel_sql/plugins/hibernate/server/HibernateServerConnectionImpl.java
  283. index ca5ef7b..33c39b7 100644
  284. --- a/sql12/plugins/hibernate/src/main/java/net/sourceforge/squirrel_sql/plugins/hibernate/server/HibernateServerConnectionImpl.java
  285. +++ b/sql12/plugins/hibernate/src/main/java/net/sourceforge/squirrel_sql/plugins/hibernate/server/HibernateServerConnectionImpl.java
  286. @@ -4,7 +4,15 @@ import java.rmi.RemoteException;
  287. import java.sql.Connection;
  288. import java.sql.DatabaseMetaData;
  289. import java.sql.SQLException;
  290. -import java.util.*;
  291. +import java.util.ArrayList;
  292. +import java.util.Collection;
  293. +import java.util.Collections;
  294. +import java.util.Date;
  295. +import java.util.HashMap;
  296. +import java.util.List;
  297. +import java.util.Map;
  298. +import java.util.Properties;
  299. +import java.util.TreeMap;
  300.  
  301. public class HibernateServerConnectionImpl implements HibernateServerConnection
  302. {
  303. @@ -121,15 +129,14 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  304. for (ReflectionCaller persister : persisters)
  305. {
  306. Object entityMode_POJO = persister.getClass("org.hibernate.EntityMode", _cl).getField("POJO").getCallee();
  307. - Class mappedClass = (Class) persister.callMethod("getMappedClass", new Object[]{entityMode_POJO}).getCallee();
  308. -
  309. + Class mappedClass = (Class) persister.callMethod("getMappedClass").getCallee();
  310. +
  311. String identifierPropertyName = (String) persister.callMethod("getIdentifierPropertyName").getCallee();
  312.  
  313. Class identifierPropertyClass = persister.callMethod("getIdentifierType").callMethod("getReturnedClass").getCalleeClass();
  314.  
  315. String identifierPropertyClassName = identifierPropertyClass.getName();
  316.  
  317. -
  318. String tableName = (String) persister.callMethod("getTableName").getCallee();
  319. String[] identifierColumnNames = (String[]) persister.callMethod("getIdentifierColumnNames").getCallee();
  320.  
  321. @@ -141,16 +148,28 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  322.  
  323.  
  324. String[] propertyNames = (String[]) persister.callMethod("getPropertyNames").getCallee();
  325. -
  326. - HibernatePropertyInfo[] infos = new HibernatePropertyInfo[propertyNames.length];
  327. +
  328. + List<HibernatePropertyInfo> infoList = new ArrayList<HibernatePropertyInfo>();
  329. +
  330. for (int i = 0; i < propertyNames.length; i++)
  331. {
  332. ReflectionCaller propertyTypeCaller = persister.callMethod("getPropertyType", propertyNames[i]);
  333. String mayBeCollectionTypeName = propertyTypeCaller.callMethod("getReturnedClass").getCalleeClass().getName();
  334.  
  335. String propTableName = (String) persister.callMethod("getPropertyTableName", propertyNames[i]).getCallee();
  336. +
  337. String[] propertyColumnNames = (String[]) persister.callMethod("getPropertyColumnNames", propertyNames[i]).getCallee();
  338. +
  339. + if (propertyColumnNames.length>1) {
  340. + // this should be ignored since a property having two columns is not a real property
  341. + // but denotes only a key spanning several properties
  342. + // properties declares that the contained properties form an alternate key. The name attribute allows
  343. + // an alternate key to be used as the target of a property-ref
  344. + continue;
  345. + }
  346.  
  347. + HibernatePropertyInfo propertyInfo = null;
  348. +
  349. try
  350. {
  351. // If this isn't instanceof org.hibernate.type.CollectionType a NoSuchMethodException will be thrown
  352. @@ -158,15 +177,18 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  353.  
  354. ReflectionCaller collectionMetaDataCaller = sessionFactoryImplcaller.callMethod("getCollectionMetadata", role);
  355. String typeName = collectionMetaDataCaller.callMethod("getElementType").callMethod("getReturnedClass").getCalleeClass().getName();
  356. -
  357. - infos[i] = new HibernatePropertyInfo(propertyNames[i], typeName, propTableName, propertyColumnNames);
  358. - infos[i].setCollectionClassName(mayBeCollectionTypeName);
  359. +
  360. + propertyInfo = new HibernatePropertyInfo(propertyNames[i], typeName, propTableName, propertyColumnNames);
  361. + propertyInfo.setCollectionClassName(mayBeCollectionTypeName);
  362. + infoList.add(propertyInfo);
  363. +
  364. }
  365. catch(RuntimeException e)
  366. {
  367. if(HibernateServerExceptionUtil.getDeepestThrowable(e) instanceof NoSuchMethodException)
  368. {
  369. - infos[i] = new HibernatePropertyInfo(propertyNames[i], mayBeCollectionTypeName, propTableName, propertyColumnNames);
  370. + propertyInfo = new HibernatePropertyInfo(propertyNames[i], mayBeCollectionTypeName, propTableName, propertyColumnNames);
  371. + infoList.add(propertyInfo);
  372. }
  373. else
  374. {
  375. @@ -174,7 +196,8 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  376. }
  377. }
  378. }
  379. - _infoDataByClassName.put(mappedClass.getName(), new MappedClassInfoData(mappedClass.getName(), tableName, identifierPropInfo, infos));
  380. + _infoDataByClassName.put(mappedClass.getName(),
  381. + new MappedClassInfoData(mappedClass.getName(), tableName, identifierPropInfo, infoList.toArray(new HibernatePropertyInfo[]{})));
  382. }
  383. }
  384.  
  385. @@ -184,7 +207,7 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  386. {
  387. try
  388. {
  389. - Connection con = (Connection) getRcHibernateSession().callMethod("getJDBCContext").callMethod("getConnectionManager").callMethod("getConnection").getCallee();
  390. + Connection con = (Connection) getRcHibernateSession().callMethod("getFactory").callMethod("getJdbcServices").callMethod("getConnectionProvider").callMethod("getConnection").getCallee();
  391. DatabaseMetaData md = con.getMetaData();
  392. return new HibernateSqlConnectionData(md.getURL(), md.getUserName(), md.getDriverName(), md.getDriverVersion());
  393. }
  394. @@ -298,6 +321,11 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  395. tryRollbackTx(ret);
  396. }
  397.  
  398. + if (null != queryResList)
  399. + {
  400. + ret.setQueryResultList(
  401. + new ObjectSubstituteFactory(_cl).replaceObjectsWithSubstitutes(queryResList, _infoDataByClassName));
  402. + }
  403.  
  404. try
  405. {
  406. @@ -307,13 +335,6 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  407. {
  408. ret.putSessionAdminException("Exception occurced during call of Session.clear()", prepareTransport(t));
  409. }
  410. -
  411. - if (null != queryResList)
  412. - {
  413. - ret.setQueryResultList(
  414. - new ObjectSubstituteFactory(_cl).replaceObjectsWithSubstitutes(queryResList, _infoDataByClassName));
  415. - }
  416. -
  417. return ret;
  418. }
  419.  
  420. @@ -373,7 +394,7 @@ public class HibernateServerConnectionImpl implements HibernateServerConnection
  421. RCParam rcParam = new RCParam();
  422. rcParam.add(con.getCallee(), Connection.class);
  423.  
  424. - _rcHibernateSession = new ReflectionCaller(_sessionFactoryImpl).callMethod("openSession", rcParam);
  425. + _rcHibernateSession = new ReflectionCaller(_sessionFactoryImpl).callMethod("openSession");
  426. }
  427. }
  428.  
  429. --
  430. 1.7.10.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement