-->
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: Working directly with member map
PostPosted: Mon Feb 22, 2010 1:50 pm 
Newbie

Joined: Wed Sep 16, 2009 11:06 am
Posts: 7
Ok, I have an object that (simplified to the parts I care about) looks like this:

Code:
@Entity
@Table(name = "MasterEnum")
public class MasterEnumRecord
{
   @Id
   @Column(name = "EnumId")
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Integer id;

   @CollectionOfElements(fetch = FetchType.EAGER)
   @JoinTable(name = "MasterEnumFamIdMfgIds", joinColumns = @JoinColumn(name = "EnumId"))
   private Set<FamIdMfgIdEntry> famIdMfgIdEntries;
}


The class FamIdMfgIdEntry is as follows:
Code:
@Embeddable
public class FamIdMfgIdEntry
{
   @Column(name = "FamId")
   private Integer famId;

   @Column(name = "MfgId")
   private Integer mfgId;
}


Each class of course has its necessary getters, setters, etc, but this gives you the idea of what the classes look like.

So what I need to do, ideally, would be to run a query more or less as follows: (these are pseudo queries, they don't work)

delete from FamIdMfgIdEntry f where f.famId = X.

Failing that, I need to be able to
select from MasterEnumRecord m where m.famIdMfgIdEntries contains a FamIdMfgIdEntry with famId = X.

Currently I'm iterating over all of my MasterEnumRecords and clearing the entries which contain X for FamId, but while that works, it's not elegant, and it takes way longer than this simple task should. Any help would be GREATLY appreciated


Top
 Profile  
 
 Post subject: Re: Working directly with member map
PostPosted: Wed Feb 24, 2010 6:50 pm 
Beginner
Beginner

Joined: Tue Aug 25, 2009 11:42 am
Posts: 49
From your pseudo query "delete from FamIdMfgIdEntry f where f.famId = X", it seems like u are expecting FamIdMfgIdEntry to be an entity (mapped to it's own table). However it is a component instead (because of @Embeddadble and @CollectionOfElements.

Why don't you make FamIdMfgIdEntry an entity instead?


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.