-->
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: Embeddable with null properties
PostPosted: Wed Aug 06, 2008 9:49 am 
Newbie

Joined: Fri Dec 28, 2007 12:27 pm
Posts: 2
I get a problem with Embeddable that have nullable properties. Hibernate 3.2.6.ga, Hibernate Annotations 3.3.0.ga

Code:
@Entity
public class Zone {
...

    @CollectionOfElements
    @JoinTable(name = "mediaholder", joinColumns = @JoinColumn(name = "zone_id"))
    private Set<Mediaholder> mediaholders = new HashSet<Mediaholder>();

...
}

@Embeddable
public class Mediaholder {
    private int zoneScopedId;

    @Nullable
    @Column(nullable = true)
    private String name;

...
}


When I make

Code:
zone.mediaholders.clear();
zone.mediaholders.addAll(...);
session.saveOrUpdate(zone);


Hibernate uses a set of SQLs that update Mediaholders collection:

Code:
org.hibernate.SQL - delete from mediaholder where zone_id=? and name=? and zone_scoped_id=?
org.hibernate.type.IntegerType - binding '12' to parameter: 1
org.hibernate.type.StringType - binding null to parameter: 2
org.hibernate.type.IntegerType - binding '1' to parameter: 3
org.hibernate.SQL - insert into placeholder (zone_id, name, zone_scoped_id) values (?, ?, ?)
org.hibernate.type.IntegerType - binding '12' to parameter: 1
org.hibernate.type.StringType - binding 'some super buber place to place' to parameter: 2
org.hibernate.type.IntegerType - binding '2' to parameter: 3


When name attributes of mediaholder component are null (name is optional) that queries leads to wrong result.

Code:
delete from mediaholder where zone_id=? and name=? and zone_scoped_id=?

with one of the parameters binded as null doesn't delete any row. As I understand instead that SQL should be generated:

Code:
delete from mediaholder where zone_id=? and name IS NULL and zone_scoped_id=?

to correctly remove required record.

Is this a bug or I missed something?

Den


Top
 Profile  
 
 Post subject: I got the same problem...
PostPosted: Tue Mar 24, 2009 9:05 am 
Newbie

Joined: Thu Jan 22, 2009 4:35 am
Posts: 2
Does anyone know how to solve it?


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.