PostgreSQL « Data Type « JPA Q&A





1. Java Enums, JPA and Postgres enums - How do I make them work together?    stackoverflow.com

We have a postgres DB with postgres enums. We are starting to build JPA into our application. We also have Java enums which mirror the postgres enums. Now the big question ...

2. Postgresql 8.4 reading OID style BLOBs with Hibernate    stackoverflow.com

I am getting this weird case when querying Postgres 8.4 for some records with Blobs (of type OIDs) with Hibernate. The query does return all right but when my code wants ...

3. Does grails / hibernate store Dates with miliseconds in PostgreSQL?    stackoverflow.com

I'm currently using grails with classes storing java.util.Date fields als DATETIME. However I need the precision / miliseconds to be stored as well which I think is not possible with MySQL. ...

4. In hibernate, how to make use of database time?    stackoverflow.com

I am using hibernate's timestamp method to update the last_modified value whenever my row in the table is updated. Like this:

<timestamp name="lastModified" column="last_modified" />
I am using postgres db. When Hibernate updates ...

5. Using enum vs Boolean?    stackoverflow.com

This may initially seem generic, but in fact, I am actually making the decision on which I need to use. What I am currently working on involves Employment Applications, those in which ...

6. Avoid insert 'null' values to database table via JPA    stackoverflow.com

im starting with JPA2 and feel quite comfortbale so far. But I have a problem when persisting Entities with null property values for NON NULL database fields with default value. I would ...

7. PostgreSQL: BYTEA vs OID+Large Object?    stackoverflow.com

I started an application with Hibernate 3.2 and PostgreSQL 8.4. I have some byte[] fields that were mapped as @Basic (= PG bytea) and others that got mapped as @Lob (=PG ...

8. Problem with @Temporal(TemporalType.DATE)    stackoverflow.com

Hi I want to map a field in my Java class

@Column(name = "date_of_birth")
@Temporal(TemporalType.DATE)
private Date dateOfBirth;
to a field in my table :
date_of_birth date,
but now when I try to run my application ...

9. Hibernate empty string for an equality restriction for PostgreSQL 8.3 and Oracle 11g    stackoverflow.com

Extending on How does hibernate use an empty string for an equality restriction? I am having a problem about how to check for an empty string between Oracle 11g and PostgreSQL using Hibernate ...





10. Timestamp in Hibernate    stackoverflow.com

I m quite fresh in Hibernate, i just have run my first project with Hibernate. But i want to insert some data in my postgres db, one of the column is "operationtime ...

11. How would be better to implements blog on me site    stackoverflow.com

I'm doing web application for many users. Application will has many modules - register, search, question-answer, forum and blog. I'm going to implement blog module for each users registered on my site. Blog can ...

12. Postgresql boolean[]    forum.hibernate.org

13. How to use Hibernate with MySQL and PostgreSQL in same time    forum.hibernate.org

Hello ! We have a project to develop working with MySQL or PostgreSQL. For the moment, if I change my database, I've to change the mapping. For exemple "id" in MySQL are auto-increments, and in hibernate I've to set a sequence. I would like to know if there is a solution to write only one mapping compatible with MySQL and PostgreSQL ...

14. Problems with blobs on PostgreSQL    forum.hibernate.org

I've searched older threads on this issue and see that people have successfully set up blobs on PostgreSQL, but I've tried to replicate and haven't had any luck. I'm trying to store image files in a blob column and have tried the following hbm mappings/tabledefs with no luck: Postgre datatype bytea w/ Hibernate types binary (throws a CGLIB exception on startup) ...

15. PostgreSQL insert booleans fail    forum.hibernate.org

Maybe someone will know why when I do an update my boolean fields are getting mapped as "true" and "false" and not 1 and 0 when doing inserts or updates. I'm using Hibernate 2.1.2 I have configured hibernate as so: hibernate.dialect net.sf.hibernate.dialect.PostgreSQLDialect hibernate.connection.driver_class org.postgresql.Driver hibernate.connection.url jdbc:postgresql://localhost:5432/acms hibernate.connection.username acms hibernate.connection.password acms hibernate.query.substitutions true 1, false 0 I even tried hibernate.query.substitutions true=1, false=0,1=true,0=false ...

16. PostgreSQL 7.3, Blob, and OID    forum.hibernate.org

Hi, I managed to get Blobs to work in Hibernate with PostgreSQL 7.3, but it required some tweaking. PG 7.3 and the corresponding JDBC driver appears to support ResultSet.getBlob and PreparedStatement.setBlob with OID columns. I encountered two issues while trying to implement this: - Hibernate's BlobType calls stmt.setBinaryStream instead of stmt.setBlob when the passed-in jvaa.sql.Blob is an instanceof net.sf.hibernate.Blob. setBinaryStream breaks ...





17. PostgreSQL Array type    forum.hibernate.org

18. PostgreSQL TimeStamp vs. Unix-Timestamp    forum.hibernate.org

Hi, can anyone help me with my little decision about what SQL-Type to use, either a TIMESTAMP or, as I used to until now, UnixTimestamp = Long. Mainly I use it for creation/changed dates of my records, as well as some start/ending date and time of a event table. What are the pros and cons of either one? I do not ...

19. PostgreSQL, Blob and LargeObject    forum.hibernate.org

I'm trying to use LargeObject of PostgreSQL with Hibernate but without success. There is anyone that is able to do? There is anyone that has made a custom UserType to do that? My UserType can write but not read data because in reading i'm not able to set autocommit false. Any help?

21. Blobs vs. PostgreSQL bytea and oid    forum.hibernate.org

public class Download { private long id; private Blob data; public long getId() { return id; } protected void setId(long id) { this.id = id; ...

22. PostgreSQL & Hibernate - bool not boolean ?    forum.hibernate.org

Hibernate version: 2.1.7 Mapping documents: all Name and version of the database you are using: PostgreSQL 8.0.1 The generated SQL (show_sql=true): Valid SQL struct - works alone Hi, im having trouble with Hibernate and PostgreSQL 8.0.1 not talking the same boolean thing - i have several tables with bool columns in PG8 and i enter them with 0 or 1 - ...

23. Postgresql ,UserType,Geometry type,nullDafeSet    forum.hibernate.org

Newbie Joined: Wed Apr 20, 2005 3:19 am Posts: 5 How I can implement nullSafeSet(usertype) for PGpoint type? PGpoint is a geometry type in PostgreSQL. Following code dosnt work: Code: public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { System.out.println("nullSafeSet"); if (value ...

24. PostgreSQL Dialect: what is the best practice of using blob?    forum.hibernate.org

public class BinaryBlobType implements UserType { public int[] sqlTypes() { return new int[] {Types.BLOB}; } public Class returnedClass() { return byte[].class; } ......... public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws ...

25. time outing for postgresql 8.0    forum.hibernate.org

26. SQLServer/PostgreSQL and HQL Boolean value '= true'    forum.hibernate.org

Thanks for the tips. Actually, in order to be more database vendor agnostic, I was looking for a setting that would work for BOTH (actually for any db). But I just tried it out, and it looks like using a quoted '0' and '1' works on SQLServer as well as PostgreSQL. So this will work for now, since we will only ...

27. PostgreSQL timestamp issue    forum.hibernate.org

28. blobs as inpustream with postgresql (and Sequoia)    forum.hibernate.org

Hi everyone, I need to force Hibernate to use the binary type to handle blobs. I'm trying to use Hibernate 3.1 with a PostgreSQL database and Sequoia (cluster module) in the middle. Unfortunately, Sequoia only handles Blobs as Inputstreams and does not handle oids like PostgreSQL. I tried to create a SequoiaPostgreSQLDialect which basically contains in the constructor: registerHibernateType( Types.BLOB, org.hibernate.Hibernate.BINARY.getName() ...

29. PostgreSQL blob (by OID) got trucated after update    forum.hibernate.org

public class SubjectFile { private Long id; private Blob data; private String filename; //omit getter and setter }

30. Postgresql OVERLAPS(date, date) and Hibernate Filters    forum.hibernate.org

(start1, end1) OVERLAPS (start2, end2) (start1, length1) OVERLAPS (start2, length2) This expression yields true when two time periods (defined by their endpoints) overlap, false when they do not overlap. The endpoints can be specified as pairs of dates, times, or time stamps; or as a date, time, or time stamp followed by an interval. SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS (DATE ...

31. date_trunc support in PostgreSQL Dialect?    forum.hibernate.org

32. Postgresql PGInterval (for data type Interval)    forum.hibernate.org

33. Hibernate 2, postgresql dialect and boolean types problem...    forum.hibernate.org

Hibernate version: 2.0 Name and version of the database you are using: PostgreSQL 8.2 We're having some issues in an Oracle 9i to PostgreSQL 8.2 transition. The project was done externally and has some libraries for which we lack sources... (that's why we don't have code, stacktraces and such) Problems arise at the point of session updates, and we think they're ...

34. PostgreSQL and Hibernate BLOB truncation problem    forum.hibernate.org

Hello All! I created entity with 2 BLOB columns in one table: one for image and one for thumbnail. Storing image and getting it back in another session works pretty good. But when I set thumbnail BLOB successfully, the original BLOB becomes empty. Retrieved entity returns length 0 for image BLOB. @Lob private Blob image; @Lob private Blob thumbnail; Hibernate 3.2.6, ...

35. Error when using Criteria, PostgreSQL and Boolean    forum.hibernate.org

Hi, I have written a criteria as follows. List itemList = session.createCriteria(SimpleClass.class) .add(Expression.like("HasEnded", Boolean.FALSE)) .list(); This one worked alright on MS SQL but has a problem when I try to use Postgresql. I have tried using createQuery instead of Criteria and it works too. Problem is only with Criteria and Boolean on Postgresql. Has anyone faced similar issue? Is it a ...

36. BLOB handling with Postgresql    forum.hibernate.org

Hello, I'm developing an application using JBoss 4.2.3 (and hence Hibernate 3). I have to store some XML documents in a database and I have to read, and update them. These documents will be encrypted eventually so I have defined an entity like this: @Entity public abstract class Document implements Serializable { @Id @GeneratedValue protected long id; @Lob protected byte[] content; ...

37. Hibernate/PostgreSQL Timestamp UserVersionType conflict    forum.hibernate.org

Newbie Joined: Wed Nov 14, 2007 10:23 am Posts: 5 Location: Brooklyn, NY I've been struggling to get a custom timestamp-based type to work as a UserVersionType. My type is based on HibernateUTC.java posted on the wiki here http://www.hibernate.org/100.html . I'll be updating that node "Real Soon Now" with my modified code to make the UserType usable as a UserVersionType. I ...