For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 8 replies, 4 voices, and was last updated 19 years, 10 months ago by
lhale.
-
AuthorPosts
-
Andrew ChengParticipantI watch the demo VipService was generate file->new->classes
, but suddenly it is full of codes, where are those codes come from?😮
/**
* getInstance() returns the instance of the <code>VipService</code> singleton.
*
* @return <code>VipService</code> singleton.
*/
public static synchronized VipService getInstance()
{
/*
* Creates the Singleton instance, if needed.
*
*/
if (instance == null)
{
instance = new VipService();
}
return instance;
}/**
* getVipdata() returns <code>Vipdata</code> object from database with given id. If
* the user is not found, will return null.
*
* @param id The <code>Long</code> id of desired <code>Vipdata</code>
* @return <code>Vipdata</code> with given id, if it exists. Otherwise, returns null.
*/
public Vipdata getVipdata(Long id)
{
/*
* Use the ConnectionFactory to retrieve an open
* Hibernate Session.
*
*/
Session session = null;try
{
session = SessionFactory.currentSession();
/*
* Calls the load method on the Hibernate session object
* to retrieve the Item with the provided id.
*/
return (Vipdata) session.load(Vipdata.class, id);
}
/*
* If the object is not found, i.e., no Item exists with the
* requested id, we want the method to return null rather
* than throwing an Exception.
*
*/
catch (ObjectNotFoundException onfe)
{
return null;
}
catch (HibernateException e)
{
/*
* All Hibernate Exceptions are transformed into an unchecked
* RuntimeException. This will have the effect of causing the
* user’s request to return an error.
*
*/
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}
/*
* Regardless of whether the above processing resulted in an Exception
* or proceeded normally, we want to close the Hibernate session. When
* closing the session, we must allow for the possibility of a Hibernate
* Exception.
*
*/
finally
{
if (session != null)
{
try
{
session.close();
}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}}
}}
/**
* updateItem() updates specfied <code>Item</code> through Hibernate.
*
* @param item An <code>Item</code> to be updated
*/
public void updateVipdata(Vipdata vipdata)
{
/*
* Use the ConnectionFactory to retrieve an open
* Hibernate Session.
*
*/Session session = null;
try
{
session = SessionFactory.currentSession();
/*
* Update the state of the item using the Hibernate session’s update method.
*
* Call the flush method to ensure that the object in saved.
*
*/
session.update(vipdata);
session.flush();
}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}
/*
* Regardless of whether the above processing resulted in an Exception
* or proceeded normally, we want to close the Hibernate session. When
* closing the session, we must allow for the possibility of a Hibernate
* Exception.
*
*/
finally
{
if (session != null)
{
try
{
session.close();
}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}}
}}
/**
* getItemList() returns list of all <code>Item</code> objects stored in the database.
*
* @return <code>List</code> of <code>Item</code> objects.
*/
public List getVipdataList()
{
/*
* Use the ConnectionFactory to retrieve an open
* Hibernate Session.
*
*/
Session session = null;try
{
session = SessionFactory.currentSession();
/*
* Build HQL (Hibernate Query Language) query to retrieve a list
* of all the items currently stored by Hibernate.
*/
Query query =
session.createQuery(
“select Vipdata from com.nscorp.hibernate.Vipdata Vipdata order by Vipdata.vipName”);
return query.list();}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}
/*
* Regardless of whether the above processing resulted in an Exception
* or proceeded normally, we want to close the Hibernate session. When
* closing the session, we must allow for the possibility of a Hibernate
* Exception.
*
*/
finally
{
if (session != null)
{
try
{
session.close();
}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}}
}
}/**
* addItem() inserts new <code>Item</code> into the database through Hibernate.
*
* @param item A new <code>Item</code> to be added.
*/
public void addVipdata(Vipdata data)
{Session session = null;
try
{
session = SessionFactory.currentSession();
session.save(data);
session.flush();
}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}
/*
* Regardless of whether the above processing resulted in an Exception
* or proceeded normally, we want to close the Hibernate session. When
* closing the session, we must allow for the possibility of a Hibernate
* Exception.
*
*/
finally
{
if (session != null)
{
try
{session.close();
}
catch (HibernateException e)
{
System.err.println(“Hibernate Exception” + e.getMessage());
throw new RuntimeException(e);
}}
}}
October 15, 2004 at 5:12 pm #217799
Riyad KallaMemberThis looks like generated Hibernate classes from our tool.. is that what you did?
October 15, 2004 at 6:15 pm #217818
Andrew ChengParticipantHow it is generated?
October 17, 2004 at 7:26 pm #217867
Riyad KallaMemberUsing the database explorer, you can navigate to a table in your database, right click, and then create the hibernate mappings for that table.
October 18, 2004 at 4:18 pm #217918
Andrew ChengParticipantI do not see it generate
Query query =
session.createQuery(
“select Vipdata from com.nscorp.hibernate.Vipdata Vipdata order by Vipdata.vipName”);
return query.list();October 18, 2004 at 7:40 pm #217937
support-jeffMemberThis is not the code generated by hibernate tool in ME. No clue where it comes from. Was this something you imported from a file?
October 25, 2004 at 1:40 pm #218273
Andrew ChengParticipantif you run the demo, can you tell me where these code come from.
I download the demo source code, and don’t know where it come from
during the demo process.October 25, 2004 at 1:59 pm #218275
support-jeffMemberYou will need to talk to the author of the demo. The code in question is not generated by ME. The demo was contributed by a user, so you need to contact them directlyt.
September 22, 2005 at 5:54 pm #237956
lhaleParticipantThis message has not been recovered.
-
AuthorPosts