[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3304) Where clause causes query to select from sub-class table
Thom Hehl (JIRA)
noreply at atlassian.com
Tue May 27 13:15:33 EDT 2008
Where clause causes query to select from sub-class table
--------------------------------------------------------
Key: HHH-3304
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3304
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Informix IDS 9
Reporter: Thom Hehl
If I have two classes:
public class ExcuseCode extends Code{
/**
* flag for no
*/
public static final String FLAG_NO = "N";
/**
* flag for yes
*/
public static final String FLAG_YES = "Y";
/**
* Participant must be within a certain number of miles
*/
public static final String TRIGGER_MILEAGE = "MILEAGE";
/**
* Participant must be too old
*/
public static final String TRIGGER_OVERAGE = "OVERAGE";
private static final long serialVersionUID = 1L;
@SuppressWarnings("all")
private static Log _log = LogFactory.getLog(ExcuseCode.class.getName());
private String additionalMessage;
private String autoFlag;
private String ejVisible;
private boolean remarksRequired;
private String trigger;
/**
* no-arg constructor
*/
public ExcuseCode(){
}
/**
* constructor with only the code character
*/
public ExcuseCode(char code){
setCodeChar(code);
setAdditionalMessage("default postponement");
setAutomatic(false);
setDescription("default postponement");
setShortText("default postponement");
}
/**
* copy constructor
*/
public ExcuseCode(ExcuseCode excuseCode){
setCodeChar(excuseCode.getCodeChar());
setAdditionalMessage(excuseCode.getAdditionalMessage());
setAutomatic(false);
setDescription(excuseCode.getDescription());
setShortText(excuseCode.getShortText());
}
/**
* @return the automatic
*/
public boolean isAutomatic() {
return getAutoFlag().equals(FLAG_YES);
}
/**
* @param automatic the automatic to set
*/
public void setAutomatic(boolean automatic) {
if(automatic){
setAutoFlag(FLAG_YES);
}
else{
setAutoFlag(FLAG_NO);
}
}
/**
* @return the visible
*/
public boolean isVisible() {
return getEjVisible().equals(FLAG_YES);
}
/**
* @param visible the visible to set
*/
public void setVisible(boolean visible) {
if(visible){
setEjVisible(FLAG_YES);
}
else{
setEjVisible(FLAG_NO);
}
}
/**
* A special code to indicate additional processing. Use this instead of
* code to key custom processing.
* @return the trigger
*/
public String getTrigger() {
return trigger;
}
/**
* A special code to indicate additional processing. Use this instead of
* code to key custom processing.
* @param trigger the trigger to set
*/
public void setTrigger(String trigger) {
this.trigger = trigger;
}
/**
* Upon selection, display this additional message
* @return the additionalMessage
*/
public String getAdditionalMessage() {
return additionalMessage;
}
/**
* Upon selection, display this additional message
* @param additionalMessage the additionalMessage to set
*/
public void setAdditionalMessage(String additionalMessage) {
this.additionalMessage = additionalMessage;
}
/**
* @return the remarksRequired
*/
public boolean isRemarksRequired() {
return remarksRequired;
}
/**
* @param remarksRequired the remarksRequired to set
*/
public void setRemarksRequired(boolean remarksRequired) {
this.remarksRequired = remarksRequired;
}
/**
* @return the ejVisible
*/
public String getEjVisible() {
return ejVisible;
}
/**
* @param ejVisible the ejVisible to set
*/
public void setEjVisible(String ejVisible) {
this.ejVisible = ejVisible;
}
/**
* @return the autoFlag
*/
public String getAutoFlag() {
return autoFlag;
}
/**
* @param autoFlag the autoFlag to set
*/
public void setAutoFlag(String autoFlag) {
this.autoFlag = autoFlag;
}
and
public class DisqualificationCode extends ExcuseCode {
private static final long serialVersionUID = 1L;
/**
* Participant must be too old
*/
public static final String TRIGGER_OVERAGE = "OVERAGE";
/**
* Participant must be too young
*/
public static final String TRIGGER_UNDERAGE = "UNDERAGE";
/**
* Participant must be unemployed
*/
public static final String TRIGGER_UNEMPLOYED = "UNEMPLOYED";
/**
* no-arg constructor
*/
public DisqualificationCode(){
super();
}
/**
* create from a code
* @param code the code for this disqualification code
*/
public DisqualificationCode(char code){
super(code);
}
/**
* copy constructor
* @param disqCode the disqualification code being copied
*/
public DisqualificationCode(DisqualificationCode disqCode){
super(disqCode);
}
/**
* constructor from super classs
* @param exCode the excuse code being copied
*/
public DisqualificationCode(ExcuseCode exCode){
super(exCode);
}
and mapping files to match:
<hibernate-mapping>
<class name="xxx.bo.ExcuseCode" table="EXC_CODE">
<id name="codeChar" column="EXC_CODE">
<generator class="assigned"/>
</id>
<property name="description"/>
<property name="ejVisible" column="EJ_VISIBLE"/>
<property name="autoFlag" column="AUTO"/>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.acs.gs.juror.bo.DisqualificationCode" table="DIS_CODE">
<id name="code" column="DISQ_CODE" type="string">
<generator class="assigned"/>
</id>
<property name="description" type="string"/>
</class>
</hibernate-mapping>
and then run a query (using Spring):
HibernateTemplate ht = getHibernateTemplate();
if(ht==null){
String msg="HibernateTemplate is null.";
_log.error(msg);
throw new IllegalStateException(msg);
}
@SuppressWarnings("unchecked")
List<ExcuseCode> excuseCodes = ht.find(
"from ExcuseCode excusecode where ejVisible='Y' order by excusecode.description asc");
_log.debug("ExcuseCodes:" + excuseCodes);
return excuseCodes;
I get this error:
SEVERE: Column not found: EJVISIBLE in statement [select disqualifi0_.DISQ_CODE as DISQ1_5_, disqualifi0_.description as descript2_5_ from DIS_CODE disqualifi0_ where ejVisible='Y' order by disqualifi0_.description asc]
Note that I'm running select ExcuseCode, but hibernate is building a query for the DIS_CODE table which is the subclass of ExcuseCode.
Thanks.
and
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list