0

I am using PostgreSQL and SQL PowerArchitect to design a physical datamodel. As I am using Hibernate which can directly persist Java objects in the database, I thought of using Java_Object as the type in SQL PowerArchitect. When I execute the query, I get this error. Kindly let me know if the type actually doesnt exist in PostgreSQL or I am making some mistake. Googling I am unable to find many reference to the data type.

CREATE TABLE public.Product_Info (
                productinfoid VARCHAR NOT NULL DEFAULT nextval('public.product_info_productinfoid_seq'),
                productbasic VARCHAR NOT NULL,
                Product_Tags JAVA_OBJECT,
                Product_Categories JAVA_OBJECT,
                Product_Ship_Time JAVA_OBJECT,
                CONSTRAINT productinfoid PRIMARY KEY (productinfoid, productbasic)
)

INFO  15-09 10:12:04,300 - sql statement failed: ERROR: type "java_object" does not exist
2
  • I am using postgresql-9.3-1102.jdbc41 Drivers. Commented Sep 15, 2014 at 8:17
  • java_object is not datatype in Postgres (all datatypes are documented here: postgresql.org/docs/current/static/datatype.html). Why would you want to store a complete (serialized) Object as a single column in the database. This is almost always a bad idea. Commented Sep 15, 2014 at 9:33

1 Answer 1

1

When creating tables you need to use column types that are supported by your database, like: CHAR, VARCHAR NUMERIC, BLOB, etc

Hibernate takes care of the the object type to database column type mapping.

You need FKs for these relationships:

  • Product_Tags,
  • Product_Categories

and probably a DATE/TIME/TIMESTAMP for this one:

  • Product_Ship_Time

The JAVA_OBJECT is for storing Java Class objects not Java Object instances!

Check org.hibernate.type.descriptor.sql.JdbcTypeJavaClassMappings:

jdbcJavaClassMappings.put( Class.class, Types.JAVA_OBJECT );

So this type would be useful when fetching a Class object type from a database column (e.g. VARCHAR).

Sign up to request clarification or add additional context in comments.

2 Comments

I am sorry, I don't understand your point. My question is, is Java_Object not supported by PostgresSQL? I know hibernate can take care, but by directly persisting objects, it would make some of my tasks simpler.
Well, there is an option in SQL PowerArchitect. Thus the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.