Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8278749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:06:49+00:00 2026-06-08T09:06:49+00:00

I trying to build a simple lib for persistence with guice persist and some

  • 0

I trying to build a simple lib for persistence with guice persist and some other things.

I already have a AbstractDao<T>, that I can easily extend and bind the concrete implementation like a boss.

But, I want a kind of GenericDao, like this:

public abstract class GenericDao<T extends Bean> {


@Inject
private Provider<EntityManager> emp;

protected EntityManager em() {
    return emp.get();
}

public AbstractDao() {
}

protected abstract Class<T> clazz();
// ....

And if I will have just the CRUD (implemented in abstract dao) in for some bean, I want to inject GenericDao<SomeBean> like a boss.

So, I started to try some hacks, and get the following:

public abstract class AbstractPersistentModule extends AbstractModule {

    protected <T extends Bean> LinkedBindingBuilder<T> bindGenericDao(final Class<T> clazz) {
       return bind(
               new TypeLiteral<GenericDao<T>>(){}
       )./* what the hell can I do here? */;
    }
}

If I can make it work, I’ll be able to do a simple:

bindGenericDao(Pessoa.class);

Someone know a way to do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:06:50+00:00Added an answer on June 8, 2026 at 9:06 am

    See this post for a working implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to build a simple test program that uses atomic operations, I get
I'm trying to build a simple html page which include some text paragraph, during
I'm trying to build a very simple OpenGL-app under Ubuntu 10.04 (I have a
I am currently trying to build some test code that uses Google C++ Test
I just started trying to build simple GUIs because I've always used command-line script
i am trying to build simple php crawler for this purpose i am getting
I am trying to build a simple script which must be able to navigate
I'm trying to build a simple user setting feature for my school project. I've
I am trying to build a simple custom editor in the Eclipse environment. To
I'm trying to build a simple Maps app based on the hello map tutorial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.