Hej i didnt wont to spam unnesesery data but i will try to write everything
my hql
Code:
"select " +
"wod.id, " +
"wod.symbol, " +
"wod.warehouseName, "+
"wod.creationDate, " +
"docIr.clientRequestSymbol, " +
"from " +
"WarehouseOutcomeDocEJB wod left join wod.baseDocument as docIr " +
"where " +
"wod.creationDate >= :startDate and wod.creationDate <= :endDate order by wod.symbol ")
Code:
@Table(name = "WarehouseOutcomeDoc")
@javax.persistence.Entity
@OnDelete( action = OnDeleteAction.CASCADE)
public class WarehouseOutcomeDocEJB extends DocumentEJB implements WarehouseOutcomeDoc {
private String warehouseName;
@Column(name="warehouse_name");
public String getWarehouseName(){
return this.wareouseName;
}
public void setWarehouseName(String warehouseName){
this.warehouseName = warehouseName;
}
}
@Table(name = "Document")
@javax.persistence.Entity
@Inheritance( strategy = InheritanceType.JOINED)
public abstract class DocumentEJB extends implements Document {
private Integer id;
private String symbol;
private DocumentEJB baseDocument;
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "baseDocumentId", updatable=true)
public DocumentEJB getBaseDocument() {
return baseDocument;
}
public void setBaseDocument( Document baseDocument) {
this.baseDocument = (DocumentEJB) baseDocument;
}
@Column(name = "symbol", updatable = true, unique = true)
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol){
this.symbol = symbol;
}
@Id
@GeneratedValue( strategy = GenerationType.AUTO)
public Integer getId() {
return this.id;
}
public void setId( Integer id) {
this.id = id;
}
}
@Table(name = "InternalRequest")
@javax.persistence.Entity
@OnDelete(action = OnDeleteAction.CASCADE)
public class InternalRequestEJB extends DocumentEJB implements InternalRequest {
private String clientRequestSymbol;
public String getClientRequestSymbol() {
return this.clientRequestSymbol;
}
public void setClientRequestSymbol(String clientRequestSymbol) {
this.clientRequestSymbol = clientRequestSymbol;
}
}
and every WarehouseDocument has set as baseDocument InternalRequest and when i try to retrive
clientRequestSymbol from baseDocument of WarehouseOutcomeDocEJB i get
Code:
15:36:38,157 ERROR [JDBCExceptionReporter] Unknown column 'documentej2_4_.clientRequestSymbol' in 'field list'
15:36:38,158 INFO [STDOUT] javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
15:36:38,158 INFO [STDOUT] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:562)
15:36:38,158 INFO [STDOUT] at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:56)
15:36:38,158 INFO [STDOUT] at pl.wroc.si.baks.session.WarehouseServiceEJB.getWarehouseOutcomeDoc(WarehouseServiceEJB.java:197)
15:36:38,158 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:36:38,159 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
15:36:38,159 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
15:36:38,159 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
15:36:38,159 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
15:36:38,159 INFO [STDOUT] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.ja
va:54)
15:36:38,159 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
whene i replace clientRequestSymbol with symbol i works fine...
Code:
"select " +
"wod.id, " +
"wod.symbol, " +
"wod.warehouseName, "+
"wod.creationDate, " +
"docIr.symbol, " +
"from " +
"WarehouseOutcomeDocEJB wod left join wod.baseDocument as docIr " +
"where " +
"wod.creationDate >= :startDate and wod.creationDate <= :endDate order by wod.symbol ")
it looks for me that hibernate do not know that baseDocument has clientRequestSymbol field because it map on DocumentEJB so is there a way to cast it on InternalRequest in hql ?