-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem using HSQL SQLException: Integrity constraint
PostPosted: Thu Oct 28, 2010 7:48 am 
Newbie

Joined: Thu Oct 07, 2010 11:19 am
Posts: 6
Hi,
I'm getting the next exception

Caused by: java.sql.SQLException: Integrity constraint violation - no parent FK383D52B87BA459A7 table: C in statement [insert into A (id, creation_time, description, version, file_extension, document_name, document_type, entity_id, entity_type, real_path) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
At the next usage:
1)I have an entity A:
Code:
public class A{

   private String name;
   private Long entityId;
   private String entityType;

    @Column(name = "entity_id")
    public Long getEntityId() {
        return entityId;
    }

    public void setEntityId(Long entityId){
        this.entityId=entityId;
    }

        @Column(name = "entity_type")
    public String getEntityType() {
        return entityType;
    }

    public void setEntityType(String entityType) {
        this.entityType = entityType;
    }
}


2)Now, I want to map another two entities to the A entity, refering to the entityId and the entityType
here is the code for both of hte entities:

Code:
public class B{

    ........
    ........
    ........
    Set<A> As;

    @OneToMany()
    @JoinColumn(name = "entity_id", referencedColumnName = "id")
    @Where(clause = "entity_type = 'B'")
    @OrderBy("creationTime DESC")
    public Set<A> getAs() {
        return As;
    }

    public void setAs(Set<A> As) {
        this.As = As;
    }
}

//=====================================================

public class B{

    ........
    ........
    ........
   Set<A> As;

    @OneToMany()
    @JoinColumn(name = "entity_id", referencedColumnName = "id")
    @Where(clause = "entity_type = 'C'")
    @OrderBy("creationTime DESC")
    public Set<A> getAs() {
        return As;
    }

    public void setAs(Set<A> As) {
        this.As = As;
    }
}


Just making clear :
1) When I use the
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
There is no issue at all, everything goes smooth.
The problem is when I use :
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class=org.hsqldb.jdbcDriver.

2)When I remove one of B or C there is no issue.


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

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.