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 6948841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:52:33+00:00 2026-05-27T13:52:33+00:00

i want to use hibernate with embedded derby in a standalone application , and

  • 0

i want to use hibernate with embedded derby in a standalone application, and i have some questions:

  1. What jars do i need ?
  2. What are the necessary hibernate configuration ?
  3. Are there any other necessary configuration ?
  4. Does it have any problems/limitations with queries/criteria ?

if you can also suggest me some good tutorial for this approach that will be preferable, thanks in advance.

  • 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-05-27T13:52:33+00:00Added an answer on May 27, 2026 at 1:52 pm

    I use Apache Derby with Hibernate for testing one of my project’s model classes (their equals, hashCode implementations, queries, etc.). MySQL is used as the production database. I choose Derby instead of HSQLDB, because I’ve experienced some incompatibilities with Hibernate and HSQLDB, meaning, given my entities (their name, schema, keys) and their relation Hibernate couldn’t create my database schema in HSQLDB, while it could with Derby. That said, maybe I messed up something; also the incompatibilities could have been resolved.

    Anyway, here is what I use in my tests (I’ve modified my pom.xml so that it would include Derby as a runtime dependency and run a single test, just to make sure it’s working).

    pom.xml

    <dependencies>                                      
      ...                               
      <dependency>                                      
        <groupId>org.hibernate</groupId>                
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.8.Final</version>                  
      </dependency>                                     
      <dependency>                                      
        <groupId>org.apache.derby</groupId>             
        <artifactId>derby</artifactId>                  
        <version>10.8.2.2</version>                     
        <scope>runtime</scope>                          
      </dependency>                                     
      <!-- 
         an slf4j implementation is needed by
         hibernate so that it could log its *stuff*
      -->
      <dependency>                                      
        <groupId>org.slf4j</groupId>                    
        <artifactId>slf4j-simple</artifactId>           
        <version>1.6.4</version>                        
        <scope>runtime</scope>                          
      </dependency>                                     
      ...                             
    </dependencies>                                     
    

    persistence.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
      version="2.0">
      <persistence-unit name="test">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>Test</class>
        <properties>
          <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
          <!--
            if you don't have a database already created
            append ;create=true to end of the jdbc url
          -->
          <property name="javax.persistence.jdbc.url" value="jdbc:derby:test"/>
          <property name="javax.persistence.jdbc.user" value="root"/>
          <property name="javax.persistence.jdbc.password" value="root"/>
          <!--  
            if you just created the database, maybe
            you want hibernate to create a schema for you
    
            <property name="hibernate.hbm2ddl.auto" value="create"/> 
          -->
        </properties>
      </persistence-unit>
    </persistence>
    

    Test entity

    @Entity
    @Table(name = "test")
    public class Test {
    
      @Id
      public int id;
    
      @Basic
      public String data;
    }
    

    Test

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("test");  
    EntityManager em = emf.createEntityManager();                               
    EntityTransaction tx = em.getTransaction();                                 
    
    Test test = em.find(Test.class, 1);                                         
    if (test == null) {                                                         
      test = new Test();                                                        
      test.id = 1;                                                              
      test.data = "a";                                                          
    
      tx.begin();                                                               
      em.persist(test);                                                         
      tx.commit();                                                              
    }                                                                           
    
    System.out.format("Test{id=%s, data=%s}\n", test.id, test.data);            
    
    em.close();                                                                 
    emf.close();    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Spring MVC web-application. I want to use Hibernate and AJAX. There are
i want use some data from a website with web service. i have a
I have a multi module maven web application, which uses hibernate. I use the
I have a list of IDs in a String, and want to use Hibernate
I want to use Infinispan with hibernate second level cache. My application is running
I have a MySQL table for persistence of some Java objects and use Hibernate
I am developing an application in struts 1.2 framework. I want to use hibernate
I want to use the Hibernate Search full text search capabilities. I have a
I have a Project with Spring and Hibernate and I want to use Hibernate
I want to use hibernate against an existing database. I need to mostly read

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.