Hibernate version: 3.0.2
Database: MySQL4.
DB Driver: com.mysql.jdbc.Driver
Pool: none explicit.
Hi, I'm using hibernate EJB3 annotations (javax.persistence)
and found hibernate not to work CORRECTLY.
I mapped my classes as follows:
<mapping package="ep" />
<mapping class="Account"/>
<mapping class="AccountAdditional_data"/>
<mapping class="AccountContact"/>
<mapping class="AccountEntity"/>
<mapping class="AccountStatus"/>
hibernate supports this configuration using
AnnotationConfiguration and is loaded as follows
in my HibernateUtil:
new AnnotationConfiguration().configure(myFile).buildSessionFactory();
the configuration seem to load alright, but still,
when trying to access information, hibernate
does not retrieve any object.
I tried an HQL query as follows:
Query query = session.createQuery("from Account");
List<Account> accounts = query.list();
My database has 34 records for the account table,
here's the annotated class:
import javax.persistence.GenerationType;
import javax.persistence.Id;
@javax.persistence.Entity(name="Account")
@javax.persistence.Table(name="account",catalog="emsdb",uniqueConstraints = { })
public class Account {
private java.lang.Long IdOffice;
private java.lang.String AccountStatus;
private java.util.Date ModificationDate;
private java.lang.Long IdAccount;
private java.lang.String Deleted;
private java.lang.Long IdCompany;
private java.lang.String Name;
private java.lang.Long IdContact;
private java.util.Date CreationDate;
@javax.persistence.Column
(name="id_office",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.Long getIdOffice() {
return this.IdOffice;
}
public void setIdOffice(java.lang.Long param) {
this.IdOffice = param;
}
@javax.persistence.Column
(name="account_status",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.String getAccountStatus() {
return this.AccountStatus;
}
public void setAccountStatus(java.lang.String param) {
this.AccountStatus = param;
}
@javax.persistence.Column
(name="modification_date",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.util.Date getModificationDate() {
return this.ModificationDate;
}
public void setModificationDate(java.util.Date param) {
this.ModificationDate = param;
}
@Id
@javax.persistence.GeneratedValue(strategy=GenerationType.AUTO)
@javax.persistence.Column
(name="id_account",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.Long getIdAccount() {
return this.IdAccount;
}
public void setIdAccount(java.lang.Long param) {
this.IdAccount = param;
}
@javax.persistence.Column
(name="deleted",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.String getDeleted() {
return this.Deleted;
}
public void setDeleted(java.lang.String param) {
this.Deleted = param;
}
@javax.persistence.Column
(name="id_company",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.Long getIdCompany() {
return this.IdCompany;
}
public void setIdCompany(java.lang.Long param) {
this.IdCompany = param;
}
@javax.persistence.Column
(name="name",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.String getName() {
return this.Name;
}
public void setName(java.lang.String param) {
this.Name = param;
}
@javax.persistence.Column
(name="id_contact",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.lang.Long getIdContact() {
return this.IdContact;
}
public void setIdContact(java.lang.Long param) {
this.IdContact = param;
}
@javax.persistence.Column
(name="creation_date",
unique=false, nullable=false,
insertable=true, updatable=true
)
public java.util.Date getCreationDate() {
return this.CreationDate;
}
public void setCreationDate(java.util.Date param) {
this.CreationDate = param;
}
as you might appreciate, it's completely correct.
Still... i'm getting an empty list.
If I use an hbm file it works correctly,
but for annotations it wont work using cfg
neither using the api to load classes.
Any idea will be extremelly appreciated.
Best regards,
_________________ Anibal Ambertin
Enterprise Architect
|