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

  • SEARCH
  • Home
  • 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 8665917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:36:06+00:00 2026-06-12T17:36:06+00:00

I am having a hard time deciding if I should stick with Hibernate for

  • 0

I am having a hard time deciding if I should stick with Hibernate for a new project, or get my feet wet with JPA and the new Spring Data implementation.

Is the Spring Data framework intended for large projects or small projects with modest query requirements?

While I certainly see the advantage in code reduction by using the @Query annotation, what do you do for dynamic queries? What about when you want to implement a save() method that’s quite complex?

The documentation says to make a Custom interface and implementation that your main repository implements, but what if you need to access any super methods on the crud repository itself? The crud repository implements the custom one – not the other way around. It seems like an odd design.

I am very uncertain whether this framework will meet the challenges of complex and large applications. I’ve never ran into many problems with Hibernate, and I’m considering sticking with the good old reliable rather than go with Spring Data JPA.

What should I do? What unforeseen complications and costs will I encounter if I go with Spring Data JPA?

  • 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-12T17:36:07+00:00Added an answer on June 12, 2026 at 5:36 pm

    So, spring-data does some extra magic that helps with complex queries. It is strange at first and you totally skip it in the docs but it is really powerful and useful.

    It involves creating a custom Repository and a custom `RepositoryImpl’ and telling Spring where to find it. Here is an example:

    Configuration class – point to your still-needed xml config with annotation pointing to your repositories package (it looks for *Impl classes automatically now):

    @Configuration
    @EnableJpaRepositories(basePackages = {"com.examples.repositories"})
    @EnableTransactionManagement
    public class MyConfiguration {
    }
    

    jpa-repositories.xml – tell Spring where to find your repositories. Also tell Spring to look for custom repositories with the CustomImpl file name:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    
    <jpa:repositories base-package="com.example.repositories" repository-impl-postfix="CustomImpl" />
    
    </beans>
    

    MyObjectRepository – this is where you can put annotated and unannotated query methods. Note how this repository interface extends the Custom one:

    @Transactional
    public interface MyObjectRepository extends JpaRepository<MyObject, Integer>, MyObjectRepositoryCustom {
    
        List<MyObject> findByName(String name);
    
        @Query("select * from my_object where name = ?0 or middle_name = ?0")
        List<MyObject> findByFirstNameOrMiddleName(String name);
    }
    

    MyObjectRepositoryCustom – repository methods that are more complex and cannot be handled with a simple query or an annotation:

    public interface MyObjectRepositoryCustom {
    
        List<MyObject> findByNameWithWeirdOrdering(String name);
    }
    

    MyObjectRepositoryCustomImpl – where you actually implement those methods with an autowired EntityManager:

    public class MyObjectRepositoryCustomImpl implements MyObjectRepositoryCustom {
    
        @Autowired
        private EntityManager entityManager;
    
        public final List<MyObject> findByNameWithWeirdOrdering(String name) {
            Query query = query(where("name").is(name));
            query.sort().on("whatever", Order.ASC);
            return entityManager.find(query, MyObject.class);
        }
    }
    

    Amazingly, this all comes together and methods from both interfaces (and the CRUD interface, you implement) all show up when you do:

    myObjectRepository.
    

    You will see:

    myObjectRepository.save()
    myObjectRepository.findAll()
    myObjectRepository.findByName()
    myObjectRepository.findByFirstNameOrMiddleName()
    myObjectRepository.findByNameWithWeirdOrdering()
    

    It really does work. And you get one interface for querying. spring-data really is ready for a large application. And the more queries you can push into simple or annotation only the better off you are.

    All of this is documented at the Spring Data Jpa site.

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

Sidebar

Related Questions

I'm having hard time trying to figure out how to auto-save user data in
I am having hard time digesting this syntax: void* operator new[](std::size_t, const std::nothrow_t&) throw();
I am new here, but I am having hard time figuring out how to
i am having hard time determining the length of a Decimal data type. The
I'm new to Django, and i'm having hard time including css styles in a
I'm having hard time deciding which name to choose for my method. I think
I'm having hard time with this project, I'm building a boat configurator which is
I am having hard time deciding what is better (in terms of performance) to
I'm having hard time to get the right solution for this, so I need
I'm having a hard time deciding which Open Session In View to use: configuring

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.