-->
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: @OneToMany with @JoinColumns issue
PostPosted: Wed Aug 26, 2009 2:10 pm 
Newbie

Joined: Mon Jun 01, 2009 11:03 am
Posts: 3
I am having a issue with onetomany with composite primary key, and I am trying to solve this for some time with no luck

Parent Class

@Entity
@Table(name = "dwf_storagegroupsnapshot")
public class DMFStorageGroupSnapshotFact extends SPMFact implements Serializable
{
@Id
private LogicalSnapshotFactPK id;

@Column(name="devicecount")
private Integer deviceCount;

@Column(name="devicemetacount")
private Integer metaCount;

@Column(name="capacity")
private Integer capacity;

@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
@JoinColumns({
@JoinColumn(name="arraykey",referencedColumnName="arraykey",nullable=false,insertable=true,updatable=true),
@JoinColumn(name="timekey",referencedColumnName="timekey",nullable=false,insertable=true,updatable=true),
@JoinColumn(name="logicalkey",referencedColumnName="logicalkey",nullable=false,insertable=true,updatable=true)
})
private List<DMFStorageTierSnapshotFact> tierFacts;

/**
* Description: Ctor
*/
public DMFStorageGroupSnapshotFact()
{ }

---> Removed getter and setters
}


Child Class -

@Entity
@Table(name = "dwf_storagetiersnapshot")
@IdClass(TierSnapshotFactPK.class)
public class DMFStorageTierSnapshotFact implements Serializable
{

@Id
@Column(name="arraykey",insertable=false,updatable=false)
private Long arrayKey;

@Id
@Column(name="timekey",insertable=false,updatable=false)
private Long timeKey;

@Id
@Column(name="logicalkey",insertable=false,updatable=false)
private Long logicalKey;

@Id
@Column(name="tiernumber")
private Integer tierNumber;

@Column(name="tiername")
private String tierName;

@Column(name="target")
private Integer target;

@Column(name="actual")
private Integer actual;

@Column(name="tiertype")
private String tierType;

@ManyToOne
@JoinColumns({
@JoinColumn(name="arraykey", insertable=false, updatable=false),
@JoinColumn(name="timekey", insertable=false, updatable=false),
@JoinColumn(name="logicalkey", insertable=false, updatable=false)
})
private DMFStorageGroupSnapshotFact sgSnapshotFact;

public DMFStorageTierSnapshotFact()
{}

}


1. First issue when I generate query using these classes keys are not mapped correctly in OneToMany relation it comes out some thing like "left outer join dwf_storagetiersnapshot tierfacts5_ on this_.arrayKey=tierfacts5_.arraykey and this_.logicalKey=tierfacts5_.timekey and this_.timeKey=tierfacts5_.logicalkey"

2. Second all the primary key columns from the child table is repeated in the select.

Appreciate any help on this.

Thanks.


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.