Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Exception [Unknown entity com. businessobjects. UserDataBO]

 
S.R.K.Vivek Raju
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have writen code to persist data entered on my JSP page. I am using hibernate to do so.
I have a business object which has getters and setters which get the data from my JSP page, now i also have DAO which implements business delegate interfaces.

Now i am trying to store the data into MySql database through hibernate.

I have written the following code for my DAO.

try{


System.out.println("************Hello World 1************");
config = new Configuration().configure();
sessionFactory = config.buildSessionFactory();
System.out.println("************Hello World 2************");
config.addClass(com.businessobjects.UserDataBO.class);

System.out.println("************Hello World 3******************");

session = sessionFactory.openSession();

System.out.println("************Hello World 4******************");
Transaction tx = session.beginTransaction();
System.out.println("************Creating transaction***************");

System.out.println(userData.getFirstName());
session.save(userData);
System.out.println("**************flushing**************");
tx.commit();
session.flush();

System.out.println("**************Committing**************");
session.close();
}
catch(HibernateException he)
{
System.out.println("Hibernate Exception :"+he.getLocalizedMessage());
}
return userData;
}

****************************************************************************
My business Object code is as follows with getter and setter methods.
****************************************************************************
public class UserDataBO implements java.io.Serializable {

// Fields

private java.lang.Integer Id;
private java.lang.String Login;
private java.lang.String Password;
private java.lang.String FirstName;
private java.lang.String LastName;
private java.lang.Character MiddleInitial;
private java.util.Date PasswordCreationDatetime;
private java.util.Date RegistrationDatetime;
private java.util.Date LoginDatetime;
private java.util.Date LogoutDatetime;
private java.lang.String MachineName;
private java.lang.String EmailAddress;
private java.lang.String Timezone;
private java.lang.Character AckTerms;
private java.lang.Integer Status;


// Constructors

/** default constructor */
public UserDataBO() {
}

/** constructor with id */
public UserDataBO(java.lang.Integer Id) {
this.Id = Id;
}
// Property accessors
/**
*/
public java.lang.Integer getId () {
return this.Id;
}

public void setId (java.lang.Integer Id) {
this.Id = Id;
}
/**
*/
public java.lang.String getLogin () {
return this.Login;
}

public void setLogin (java.lang.String Login) {
this.Login = Login;
}
/**
*/
public java.lang.String getPassword () {
return this.Password;
}

public void setPassword (java.lang.String Password) {
this.Password = Password;
}
/**
*/
public java.lang.String getFirstName () {
return this.FirstName;
}

public void setFirstName (java.lang.String FirstName) {
this.FirstName = FirstName;
}
/**
*/
public java.lang.String getLastName () {
return this.LastName;
}

public void setLastName (java.lang.String LastName) {
this.LastName = LastName;
}
/**
*/
public java.lang.Character getMiddleInitial () {
return this.MiddleInitial;
}

public void setMiddleInitial (java.lang.Character MiddleInitial) {
this.MiddleInitial = MiddleInitial;
}
/**
*/
public java.util.Date getPasswordCreationDatetime () {
return this.PasswordCreationDatetime;
}

public void setPasswordCreationDatetime (java.util.Date PasswordCreationDatetime) {
this.PasswordCreationDatetime = PasswordCreationDatetime;
}
/**
*/
public java.util.Date getRegistrationDatetime () {
return this.RegistrationDatetime;
}

public void setRegistrationDatetime (java.util.Date RegistrationDatetime) {
this.RegistrationDatetime = RegistrationDatetime;
}
/**
*/
public java.util.Date getLoginDatetime () {
return this.LoginDatetime;
}

public void setLoginDatetime (java.util.Date LoginDatetime) {
this.LoginDatetime = LoginDatetime;
}
/**
*/
public java.util.Date getLogoutDatetime () {
return this.LogoutDatetime;
}

public void setLogoutDatetime (java.util.Date LogoutDatetime) {
this.LogoutDatetime = LogoutDatetime;
}
/**
*/
public java.lang.String getMachineName () {
return this.MachineName;
}

public void setMachineName (java.lang.String MachineName) {
this.MachineName = MachineName;
}
/**
*/
public java.lang.String getEmailAddress () {
return this.EmailAddress;
}

public void setEmailAddress (java.lang.String EmailAddress) {
this.EmailAddress = EmailAddress;
}
/**
*/
public java.lang.String getTimezone () {
return this.Timezone;
}
public void setTimezone (java.lang.String Timezone) {
this.Timezone = Timezone;
}
/**
*/
public java.lang.Character getAckTerms () {
return this.AckTerms;
}
public void setAckTerms (java.lang.Character AckTerms) {
this.AckTerms = AckTerms;
}
/**
*/
public java.lang.Integer getStatus () {
return this.Status;
}
public void setStatus (java.lang.Integer Status) {
this.Status = Status;
}

}
****************************************************************************
Now when i click on submit button on my JSP page the following error comes up on my Jboss console.

11:23:00,453 INFO [STDOUT] ************Hello World 1************
11:23:00,453 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
11:23:00,453 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
11:23:00,453 INFO [Configuration] Configured SessionFactory: ehaa
11:23:00,453 INFO [Configuration] processing extends queue
11:23:00,453 INFO [Configuration] processing collection mappings
11:23:00,453 INFO [Configuration] processing association property references
11:23:00,453 INFO [Configuration] processing foreign key constraints
11:23:00,453 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
11:23:00,453 INFO [SettingsFactory] Maximum outer join fetch depth: 2
11:23:00,468 INFO [SettingsFactory] Default batch fetch size: 1
11:23:00,468 INFO [SettingsFactory] Generate SQL with comments: disabled
11:23:00,468 INFO [SettingsFactory] Order SQL updates by primary key: enabled
11:23:00,468 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTr
anslatorFactory
11:23:00,484 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
11:23:00,484 INFO [SettingsFactory] Query language substitutions: {}
11:23:00,484 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connectio
n pool (not for production use!)
11:23:00,484 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20

11:23:00,500 INFO [DriverManagerConnectionProvider] autocommit mode: false
11:23:00,500 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Drive
r at URL: jdbc:mysql://localhost:3306/eh
11:23:00,500 INFO [DriverManagerConnectionProvider] connection properties: {user=, pas
sword=}
11:23:00,546 INFO [SettingsFactory] JDBC batch size: 15
11:23:00,546 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
11:23:00,546 INFO [SettingsFactory] Scrollable result sets: enabled
11:23:00,546 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
11:23:00,546 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.tran
saction.JDBCTransactionFactory
11:23:00,546 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup config
ured (in JTA environment, use of read-write or transactional second-level cache is not
recommended)
11:23:00,546 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disable
d
11:23:00,546 INFO [SettingsFactory] Automatic session close at end of transaction: dis
abled
11:23:00,578 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCache
Provider
11:23:00,578 INFO [SettingsFactory] Second-level cache: enabled
11:23:00,593 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
11:23:00,593 INFO [SettingsFactory] Structured second-level cache entries: enabled
11:23:00,593 INFO [SettingsFactory] Query cache: disabled
11:23:00,593 INFO [SettingsFactory] Echoing all SQL to stdout
11:23:00,593 INFO [SettingsFactory] Statistics: disabled
11:23:00,593 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disa
bled
11:23:00,593 INFO [SettingsFactory] Default entity-mode: pojo
11:23:00,593 INFO [SessionFactoryImpl] building session factory
11:23:00,593 INFO [SessionFactoryObjectFactory] Factory name: ehaa
11:23:00,593 INFO [NamingHelper] JNDI InitialContext properties:{}
11:23:00,593 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: ehaa
11:23:00,593 WARN [SessionFactoryObjectFactory] InitialContext did not implement Event
Context
11:23:00,593 INFO [SessionFactoryImpl] Checking 0 named queries
11:23:00,593 INFO [STDOUT] ************Hello World 2************
11:23:00,625 INFO [Configuration] Mapping resource: com/businessobjects/UserDataBO.hbm
.xml
11:23:00,640 INFO [HbmBinder] Mapping class: com.businessobjects.UserDataBO -> user
11:23:00,640 INFO [STDOUT] ************Hello World 3******************
11:23:00,640 INFO [STDOUT] ************Hello World 4******************
11:23:00,640 INFO [STDOUT] ************Creating transaction***************
11:23:00,640 INFO [STDOUT] vivekraju
11:23:00,640 INFO [STDOUT] Hibernate Exception :Unknown entity: com.businessobjects.UserDataBO
****************************************************************************
I have checked my .hbm.xml file and the database column and they match perfectly.I still could not figure it out, if anybody has undergone through such type of problem or is aware of it, please guide me through this.

Thanks a lot,
With Regards
S.R.K.Vivek Raju.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic