Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #40007

Re: Is there a simpler way to map Hibernate?

Path csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Is there a simpler way to map Hibernate?
Date Fri, 1 Sep 2023 09:37:42 -0400
Organization A noiseless patient Spider
Lines 53
Message-ID <ucspf7$3ppii$1@dont-email.me> (permalink)
References <015e1e01-2e15-49bf-ae5e-07470e4e3d2bn@googlegroups.com> <ucr57u$3fa1g$1@dont-email.me> <c7dbfc66-c143-45f0-8501-50d9aa90e3b2n@googlegroups.com> <ucslb3$3p6nj$1@dont-email.me> <f0746a5b-9125-4055-b2a4-de230c621f6cn@googlegroups.com> <ucsnkr$3pftv$1@dont-email.me> <69105518-21d7-468c-9774-e9ffb497677fn@googlegroups.com>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 1 Sep 2023 13:37:43 -0000 (UTC)
Injection-Info dont-email.me; posting-host="cb85e14bf167dff1355501843a4c18ca"; logging-data="3991122"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GFwKdLmcyrsG04ml3A8Goqjpi+lU8o3w="
User-Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0
Cancel-Lock sha1:4aqQZ+OBfCms2jS+f7o2fxq/4lo=
Content-Language en-US
In-Reply-To <69105518-21d7-468c-9774-e9ffb497677fn@googlegroups.com>
Xref csiph.com comp.lang.java.programmer:40007

Show key headers only | View raw


On 9/1/2023 9:25 AM, e.d.pro...@gmail.com wrote:
>> So you are not using JPA with Hibernate as implementation - you are
>> using Hibernate with JPA annotations.
>> 
>> I believe that is supposed to work, but most people changed from
>> Hibernate with XML to JPA with annotations like 15 years ago.
>> 
>> I have no idea about how Hibernate with JPA annotations. work.
>> 
>> Any chance that you could change to JPA?
>> 
> What is "JPA with Hibernate" versus "Hibernate with JPA annotations"?
> Is this just about using persistence.xml files with EntityManager?
> That still requires declaring every entity class in the xml file and
> duplicating that for test? What is the advantage?

Yes. Basically:

EntityManagerFactory emf = Persistence.createEntityManagerFactory(confnam);
EntityManager em = emf.createEntityManager();

instead of:

SessionFactory sf = new Configuration().configure(new 
File(conffile)).buildSessionFactory();
Session s = sf.openSession();

(your setup code is a little bit more advanced but above
is the basic version)

I see two advantages.

1) You switch to a mode that almost everyone else is using
    so a lot better support and a lot easier to get help.

2) It is correct that the most common approach is to
    have a persistence.xml with:

       <class>p.C1</class>
       <class>p.C2</class>
       <class>p.C3</class>
       <exclude-unlisted-classes/>

but you could try with:

       <exclude-unlisted-classes>false</exclude-unlisted-classes>

I am not an expert in the finer points of JPA, but I remember
it as that false should work in Java EE context and that it
is not guaranteed to work in SE context but usually does.

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-08-31 04:49 -0700
  Re: Is there a simpler way to map Hibernate? Arne Vajhøj <arne@vajhoej.dk> - 2023-08-31 18:46 -0400
    Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-01 04:08 -0700
      Re: Is there a simpler way to map Hibernate? Arne Vajhøj <arne@vajhoej.dk> - 2023-09-01 08:27 -0400
        Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-01 05:49 -0700
          Re: Is there a simpler way to map Hibernate? Arne Vajhøj <arne@vajhoej.dk> - 2023-09-01 09:06 -0400
            Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-01 06:25 -0700
              Re: Is there a simpler way to map Hibernate? Arne Vajhøj <arne@vajhoej.dk> - 2023-09-01 09:37 -0400
                Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-01 12:48 -0700
                Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-05 12:34 -0700
                Re: Is there a simpler way to map Hibernate? Arne Vajhøj <arne@vajhoej.dk> - 2023-09-10 20:48 -0400
                Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-11 04:19 -0700
                Re: Is there a simpler way to map Hibernate? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-09-11 05:23 -0700

csiph-web