update database schema with new "CANCELLED" status

3 views
Skip to first unread message

transmeta01

unread,
Jan 31, 2011, 6:12:21 PM1/31/11
to classic dev
public enum Status {

PROCESSED(1, "PROCESSED"),
CANCELLED(2, "CANCELLED"),
PENDING(3,"PENDING"),
REJECTED(4, "REJECTED"),
SHIPPED(5, "SHIPPED");

private final Byte id;
private final String label;

private Status(Integer id, String label) {
this.id = id.byteValue();
this.label = label;
}
public Byte getId() {
return id;
}
public String getLabel() {
return label;
}



}


Hi Cristian, in the code above, I have added an additional status:
CANCELLED(2, "CANCELLED"),. When the users cancel their order, the
status should be cancelled. Do you need to update the database schema?

Cristian Olaru

unread,
Feb 2, 2011, 8:55:39 AM2/2/11
to class...@googlegroups.com
Hi Richard.

I included this change in one of my commits.

Now I have a problem in persistence with Guice:

In UserResourceTest I create a test for UserResource. The add method try in the end to persist a user in database. The persistence in not working in GenericDao (the user is not comited in database - the returned user doesn't have a valid id). In other tests with Unitils is working because Spring is used for managing transactions. In this case Guice is use:

        <dependency>
            <groupId>com.mycila.com.google.inject.extensions</groupId>
            <artifactId>guice-persist</artifactId>
            <version>3.0-20100927</version>
        </dependency>

You must use mvn jetty:run to have the server up (with schema created) ready to receive  a REST call from UserResourceTest test.

Is something from how the Persistence Manager is configured - also this: com.google.inject.persist.Transactional is not working

See ClassicModule to see how I configure the EntityManager.

As I say I don't have eral experience with Guice. Will take a time for me to fix this. Maibe is better to migrate to Spring? Or to try: http://code.google.com/p/warp-persist.

Regards...
--
Cristian Olaru
weblog: http://olaru.blogspot.com
mobile: 0743163039

colaru

unread,
Feb 2, 2011, 10:43:28 AM2/2/11
to classic dev
Hi Richard.

It works in this way:

public void persist(T t) {
em.getTransaction().begin();
em.persist(t);
em.getTransaction().commit();

Richard Mutezintare

unread,
Feb 2, 2011, 10:43:46 AM2/2/11
to class...@googlegroups.com

Cristian Olaru

unread,
Feb 2, 2011, 1:54:05 PM2/2/11
to class...@googlegroups.com
Hi Richard.

That's is what I used. This is the dependency:

       <dependency>
            <groupId>com.mycila.com.
google.inject.extensions</groupId>
            <artifactId>guice-persist</artifactId>
            <version>3.0-20100927</version>
        </dependency>

Is true I see on MVN REPO other implentations: http://mvnrepository.com/search.html?query=guice-persist:

But id doesn't work without using explicitly transaction manipulation:


       public void persist(T t) {
               em.getTransaction().begin();
               em.persist(t);
               em.getTransaction().commit();

       }

The @Transactional annotation is not working. Maybe I made a mistake in configurations. Don't know. I will continue to investigate.

Regards...

Richard Mutezintare

unread,
Feb 2, 2011, 3:36:56 PM2/2/11
to class...@googlegroups.com
Isn`t there @Transactional annotation?

Richard Mutezintare

unread,
Feb 2, 2011, 6:37:49 PM2/2/11
to class...@googlegroups.com
Hi Cristian, you should focus on completing the DAO for all for of the entities before moving on to the integration part. Every service and DAO should pass tests independently of all the other stuff. The REST "front controller" should also be complete and tested standalone before integration. 

Regards
Richard
Reply all
Reply to author
Forward
0 new messages