Advertisement
Guest User

Untitled

a guest
Dec 29th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. select count(*) as y0_ from SUMMARY_VIEW this_ where this_.ser_id like :1 and this_.TYPE=:2 and this_.TIME_LOCAL>=:3 and this_.TIME_LOCAL<=:4
  2.  
  3. select count(*) as y0_ from SUMMARY_VIEW this_ where this_.ser_id like :ser_id and this_.TYPE=:type and this_.TIME_LOCAL>=:startdate and this_.TIME_LOCAL<=:enddate
  4.  
  5. select sql_text, v.sql_id, name, value_string, datatype_string from v$sql_bind_capture vbc join v$sql v using (hash_value) where v.sql_id in (?)
  6.  
  7. import java.io.Serializable;
  8. import java.sql.PreparedStatement;
  9. import java.sql.ResultSet;
  10. import java.sql.SQLException;
  11. import java.sql.Timestamp;
  12. import java.sql.Types;
  13. import java.util.Objects;
  14.  
  15. import oracle.sql.DATE;
  16.  
  17. import org.hibernate.engine.spi.SessionImplementor;
  18. import org.hibernate.usertype.UserType;
  19.  
  20. public class OracleDate implements UserType {
  21.  
  22. @Override
  23. public int[] sqlTypes() {
  24. return new int[] { Types.TIMESTAMP };
  25. }
  26.  
  27. @Override
  28. public Class<?> returnedClass() {
  29. return Timestamp.class;
  30. }
  31.  
  32. @Override
  33. public Object nullSafeGet(
  34. ResultSet rs,
  35. String[] names,
  36. SessionImplementor session,
  37. Object owner
  38. )
  39. throws SQLException {
  40. return rs.getTimestamp(names[0]);
  41. }
  42.  
  43. @Override
  44. public void nullSafeSet(
  45. PreparedStatement st,
  46. Object value,
  47. int index,
  48. SessionImplementor session
  49. )
  50. throws SQLException {
  51. // The magic is here: oracle.sql.DATE!
  52. st.setObject(index, new DATE(value));
  53. }
  54.  
  55. // The other method implementations are omitted
  56. }
  57.  
  58. @Entity
  59. @TypeDefs(
  60. value = @TypeDef(
  61. name = "oracle_date",
  62. typeClass = OracleDate.class
  63. )
  64. )
  65. public class Rental {
  66.  
  67. @Id
  68. @Column(name = "rental_id")
  69. public Long rentalId;
  70.  
  71. @Column(name = "rental_date")
  72. @Type(type = "oracle_date")
  73. public Timestamp rentalDate;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement