Let’s start with a short quiz. TxMergeBean is a SLSB that uses CMT and EntityManager. Assume the following local and remote business interfaces:

public interface TxMergeCommon {
    void methodA();
    void methodB(MeineEntity entity);
}

@Local
public interface TxMergeLocal {}

@Remote
public interface TxMergeRemote {} 

and the following SLSB:

@Stateless
public class TxMergeBean implements TxMergeRemote, TxMergeLocal {

    @PersistenceContext
    private EntityManager em;

    @EJB
    private TxMergeLocal self;

    @Resource
    private SessionContext sctx;

    public void methodA() {
        MeineEntity entity = new MeineEntity("methodA");
        em.persist(entity);

        self.methodB(entity);
    }

    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void methodB(final MeineEntity entity) {
        entity.setName("methodB");
        em.merge(entity);

        sctx.setRollbackOnly();
    }
}

Assume that MeineEntity is properly defined and its only constructor parameter is saved as ‘name’ attribute.

What will be the database persisted value of MeinEntity ‘name’ attribute after TxMergeBean#methodA() invocation?

Continue reading

Whoa, those few days of GeeCON – Polish Java conference – just passed way too quick. A lot of great speakers, pretty good organisation and the overwhelming Java climate. Yep, it’s geeky or even nerdy but – what the hell – me like it! ;-)

But for all of you who was not able to attend this conference – it consisted of 3 parts:

  • University Day (1 day),
  • Conference (2 days),
  • Open Spaces with Bruce Eckel (1 day).

First three days were held in Poznań’s Multikino 51 and the last one was held in the Cognifide company headquarters.

Continue reading

I’ve had some problem with starting the GlassFish database. It occurs that in GlassFish 3.1 it started together with the Application Server (when you started the domain), but this doesn’t work for me since 3.1.1.

So, if you see something like:

Error connecting to server localhost on port 1527 with message Connection refused: connect.

you can try to start the GlassFish Java DB by yourself. To do this, just invoke:

asadmin start-database

while you’re in GLASSFISH_HOME/bin directory.