Question is quite simple: is there any JDO/JPA/anything else "object-to-DB" mapping tools that can handle PG arrays? Multi-dimensional arrays? Mostly of strings and integers/longs.
Second one: can it handle hstore column types?
I'm trying to implement something to handle these types in DataNucleus JDO, but still no result. The most impressive and simple to implement support I've seen so far is python's SQLAlchemy.
The PostgreSQL JDBC Driver allows Java programs to connect to a PostgreSQL database using standard, database independent Java code.
PostgreSQL allows columns of a table to be defined as variable-length multidimensional arrays. Arrays of any built-in or user-defined base type, enum type, composite type, range type, or domain can be created.
PostgreSQL (which goes by the moniker Postgres) is famous for its object-relational nature. In contrast, other database systems are usually relational. Due to its nature, it's a great pairing with Java, which is heavily object-oriented.
setArray(2, aArray); int count = preparedStatement. executeUpdate(); System. out. println(count + " inserted");
First of, SQLAlchemy is awesome... All the stuff that others can't do out-of-the-box works like a charm in this ORM.
The solution that you might want involves Hibernate:
mapping a postgres array with hibernate might be interessting for you. Basically, all the suggestions you will see involve the writing of a UserType extension. This would also apply to Postgres Enums types (and probably hstore, but that would only be a guess). An example for such a userType could be found on the Hibernate forums. This in-depth article explains the interface fairly detailed. After writing the UserType, you only need to annotate the property and Hibernate will be able to do the mapping. In newer versions (I've used it with Hibernate 4.x) the interface has changed slightly, but nothing you can't figure out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With