-->
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: Annotated configuration does not retrieve any objects.
PostPosted: Mon May 15, 2006 7:06 pm 
Newbie

Joined: Mon May 15, 2006 6:56 pm
Posts: 1
Location: Argentina
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 2:57 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Quote:
but for annotations it wont work using cfg


What exactly won't work?
Any stack trace?

Quote:
neither using the api to load classes.


What?


Top
 Profile  
 
 Post subject: Doesn't Annotations require Hibernate 3.2.X?
PostPosted: Thu May 18, 2006 1:45 pm 
Regular
Regular

Joined: Sun Sep 21, 2003 11:43 pm
Posts: 85
Location: Massachusetts
What version of Hibernate Annotations and Hibernate Core are you using? I have this disclaimer in all versions (Beta 10 something plus 3.2.0.CR1):
=-=-=-=-=-=-

Hibernate Annotations
==================================================
Version: 3.2.0 CR1, 13.05.2006

THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE 3.2.0.CR2 AND DOES NOT WORK
WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE.

=-=-=-=-=-=-

Regards,
David


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.