Archive for the ‘Java’ Category

  • Spring vs EJB3

    I am looking at using Spring and EJB3 in a application. There are few blog entries & presentations debating on either Spring or EJB3 case. I prefer to be in EJB3(session beans) + JPA for persistence configured in Spring container camp.
    Some resources are below
    http://www.devx.com/Java/Article/32314/0/page/1
    A comparative analysis of Spring vs EJB3 by EJB3 in Action author [...]

  • Spring+JPA with Hibernate

    This is a sample of using Spring 2.5 with JPA provided by Hibernate 3.2.
    This is the model class Trip.java

    package sample.model;import javax.persistence.Entity;
    import javax.persistence.Table;
    import javax.persistence.Id;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Column;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;import java.util.Date;

    @Entity
    @Table(name = “trips”)
    @NamedQueries({
    @NamedQuery(name=”Trip.allTrips”, query=”from Trip”)
    })
    public class Trip  {

    @Id
    @GeneratedValue
    private Long id;

    @Column(length = 30)
    private String tripName;
    @Column(length = 3)
    private int duration;
    @Column(length = 20)
    private Date startDate;
    @Column(length = 500)
    private String description;

    public Long getId() [...]

  • Job Scheduler using commonj Timer in weblogic

    A Job Scheduler using commonj api on weblogic server. The commonj is supported by websphere also.
    Refer Anthony Jen’s Blog for detailed tutorial including configuring the scheduler using JMX & Spring annotations.
    The following entry should be in web.xml. This will create a Timer called BatchTimer.

    <resource-ref>
    <res-ref-name>timer/BatchTimer</res-ref-name>
    <res-type>commonj.timers.TimerManager</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    The batch timer with JNDI name is injected into the Spring bean, [...]