-->
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.  [ 3 posts ] 
Author Message
 Post subject: Stopped when mapped with Annotations
PostPosted: Tue Jan 09, 2007 3:24 pm 
Newbie

Joined: Tue Oct 03, 2006 3:35 pm
Posts: 9
Location: São Paulo
Hibernate version:

3.0.2-GA (same for annotations)

I decided to remap my java classes using Annotations.

I have one simple query that used to work but it doesn't anymore.

Where am i missing something?

This is the cenario:

One class and a Child = Simple Inheritance.

Java Classes: (simplified)

@Entity
@Table(name="ACTIVITIES)
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn( name="AUTOM", discriminatorType=DiscriminatorType.INTEGER)
@DiscriminatorValue("0")
@SequenceGenerator(name="activitySequence", sequenceName="ACTIVITIES_S1", allocationSize=1)
public class Activity {


private Long id;

private String description;

private Flow flow;


@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="activitySequence")
public Long getId(){

return this.id;
}

public void setId(Long id ){

this.id = id;
}
@ManyToOne(cascade=CascadeType.PERSIST)
@JoinColumn(name="FLOW_OID_FK")
public Flow getFluxo() {
return flow;
}

public void setFlow(Flow flow) {
this.flow = flow;
}
}

@Entity
@DiscriminatorValue("1")
public class AutomaticActivity extends Activity {


private String clazz = null;

@Column(name="CLASS")
public String getClazz() {
return classe;
}

public void setClazz(String clazz) {
this.clazz = clazz;
}
}


Query that used to work:

Count how many NonAutomatic activities i have for a desired flow:
-----------------------------------------
select size(a) from Flow f join f.activities a where a.class != AutomaticActivity and f.id = :id
-----------------------------------------

Now it only works if i explicitly set the discriminator value:
-----------------------------------------
select size(a) from Flow f join f.activities a where a.class != 1 and f.id = :id
-----------------------------------------

Note that the only the java classes have changed.


Cheers,



:Luiz.Decaro.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 10:13 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
prease provide your previous hbm mapping

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Thx.
PostPosted: Wed Jan 10, 2007 10:49 am 
Newbie

Joined: Tue Oct 03, 2006 3:35 pm
Posts: 9
Location: São Paulo
Thank you for your answer. I hate when this happen but I found out this was a silly mistake from me !!!

Unfortunately I didn't know (and hadn't noticed) I had to insert the following statement in the cfg file:

<mapping class="AutomaticActivity" />

When i was using hbm file i didn't have to insert the record for the subclasses. (because they are mapped in the same hbm, of course)


Anyway,


Thx a Lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.