-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Caveat example: Problems with Ingres Dialect
PostPosted: Tue Jun 12, 2007 4:23 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Hi,

my next project (and in effect: my first with Hibernate) project will be based on a Ingres Database. So I'm just familiarizing myself with Ingres and Hibernate.

I first tried the Caveat example in the JPA version with Ingres.

First thing I noticed: you cannot use Identity key generators with Ingres; but the example builds on those: BAD. Anyway, i changed the strategy to sequence.

Second problem: hbm2DDL produces this Create statement:

Code:
create table CATEGORY_ITEMS_BY_USER (CATEGORY_ID bigint not null, USER_ID bigint not null, ITEM_ID bigint with null, primary key (CATEGORY_ID, ITEM_ID))


so the JDBC-driver (or the database?) complains:
Code:
CREATE TABLE: A column in a UNIQUE constraint has been
defined as WITH NULL (on table 'category_items_by_user')
.

With this problem, I have no idea how to solve it. I hope there won't be more of this kind of problems with Ingres.

Can someone help?

Carlo.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 4:49 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
That column should not be NULL and Ingres seems to be one of the few databases that (correctly) complains about it. I guess you can put an optional='false' or something on the mapping in Category.java in this block:

Code:
@ManyToMany
    @org.hibernate.annotations.MapKeyManyToMany(
        joinColumns = @JoinColumn(name = "ITEM_ID")
    )
...


Note that good usecases for MapKeyManyToMany are _extremely_ rare, this is for demonstration purposes only.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.