Incompatibility while using resthub and morphia

18 views
Skip to first unread message

Vinoth Kumar

unread,
May 27, 2011, 11:36:09 AM5/27/11
to resthub-dev
Hello,

I am using mongoDb for one of my DAO (for the rest I am using MySQL).
I am using Morphia which is a lightweight type-safe library for
mapping Java objects to/from MongoDB. Before switching to mongoDB I
previously used the MySQL Dao and created the service and controller
layers

When I later switched to mongoDb using Morphia I replaced the DAO and
DAOImplementation of GenericJpaResourceDao of RestHub with BasicDAO of
Morphia.

import com.google.code.morphia.dao.BasicDAO;
@Named("poiDao")
public class POIDaoImpl extends BasicDAO<Poi, ObjectId> implements
POIDao {
..........
............
}

public interface POIDao extends DAO<Poi, ObjectId> {
............
.............
}


I am still using the same Model layer from the RestHub generic
resource.


import com.google.code.morphia.annotations.Entity;
@Entity("poi")
public class Poi extends Resource {
...........
...........
...........
}



In the service layer implementation when I try to implement the Poi
and POIDao there was an incompatibility, since the
GenericResourceServiceImpl of Poi extends Poi correctly but the PoiDao
is no longer GenericResourceDao<T> but replaced with DAO<Poi,
ObjectId> of Morphia.

@Named("poiService")
public class POIServiceImpl extends GenericResourceServiceImpl<Poi,
POIDao> implements POIService {
.............
..............
}


public abstract class GenericResourceServiceImpl<T extends Resource, D
extends GenericResourceDao<T>>

***************************************************************************************************************************************


But the real problem is this.
Due to the above mentioned incompatibility I made the following
changes in the POIDao interface.

In the POIDao interface when I included both DAO and
GenericResourceDao like the one given below, but even then there is
incompatibility since both define methods such as delete. Hence the
incompatibility.

public interface POIDao extends DAO<Poi, ObjectId>,
GenericResourceDao<Poi> {
.....
...}

***************************************************************************************************************************************


Kindly help me how to fix this.

Regards,
Vinoth

Seb

unread,
Jun 10, 2011, 1:54:20 AM6/10/11
to resth...@googlegroups.com
Hi,

... and sorry the answer delay.

In lastest 1.1-SNAPSHOT releases, we have removed Resource class and matching Dao/Service/Controller, in favor of using improved GenericDao/GenericService/GenericController. It lets your model free from RESThub dependency, avoid database join performance issues when using JPA, and give use quite the same level of functionnalities.

Resource is now provided as a sample code in documentation : http://resthub.org/java/structure.html

So in your case POI should not inherit from Resource anymore and your interface should extends GenericDao instead of GenericResourceDao.

Best regards,
Seb

Reply all
Reply to author
Forward
0 new messages