26 April 2011

Hibernate First Steps

For adding a new object (to database) the code below suffice (you still need to define xml files / JPA annotation still for hibernate configuration):



Configuration conf = new Configuration().configure(file);
SessionFactory sessionFactory = conf.buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object


Transaction tx;
tx = session.beginTransaction();

System.out.println("Inserting Record");
contact contact = new contact();
contact.setId(6);
contact.setFirstName("firstt");
contact.setLastName("lfirstt");
session.save(contact);

System.out.println("Done");

tx.commit();




This is not the whole code, you need to take into consideration the flush and close of the session.
For updating or deleting, one should know the uniqeIdentifier, if not you can use SQL query to get that (not described here how).
When you have that identifier, you just need to have the following code:




Long identifier = (long) 2;
contact contact1 = (contact) session.load(contact.class, identifier);
System.out.println(contact1.getEmail());

25 April 2011

Persistence in jBPM

Trying to persist a jBPM into a database ? and you are searching the internet for it ? that's not going to get you the best result. You might get to this page: http://docs.jboss.org/jbpm/v3/userguide/persistence.html where it says you need to use the jPBMContext but what you need to know is that you don't need to do anything. jBPM if set up correctly, it persists automatically into database. You only need to change (or use) jPBMContext where you want to change the default behavior of the system.

20 April 2011

Making external monitor the primary monitor in Linux

Making some monitor, a primary monitor is a matter of having the panels on that monitor. No one wants to work on one monitor that has panels of its machine on the other one. I have tried this on Red Hat Enterprise 6.
Here's a step-by-step way of moving a panel to another screen:
  • Right-click the panel you wish to move and select "Properties".
  • Uncheck the "Expand" option under the "General" tab.
  • Grab one of the edges of the panel by clicking on the left or right end (top or bottom end for vertical panels).
  • Drag the bar to the desired screen and position.
  • Check the "Expand" option in the "Panel Properties" window and click "Close".