You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by James <ja...@iinet.net.au> on 2022/12/19 02:11:08 UTC

data persistence using hibernate

Hi,
can anyone direct me to any resources on how to integrate hibernate for 
data persistence?

the closest I've managed to find is
https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
but there's still things that are confusing me on how to ingrate an 
authenticated application with hibernate

-- 
Best Regards
James Pollard
james.pollard@iinet.net.au


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by Vit Rozkovec <ro...@email.cz>.
Check out JDBI as well.

Vit


On 25. 01. 23 3:23, Locke, Jonathan (Luo Shibo) wrote:
> JOOQ is good for me most of the time.
>
> Jon
>
> On Jan 24, 2023, at 6:34 PM, James Pollard <ja...@iinet.net.au> wrote:
>
> I don't need hibernates added level of abstraction
>
> I was taught in the past to do database connectivity using jdbc
> drivers/connectors, hikaricp just takes this a step further
> by providing a pool of connections to use. Basically I've looked at orm
> frameworks in the past and just couldn't get my
> head around how to use it, I much prefer spelling out my query exactly
> myself.
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au<ma...@iinet.net.au>
>
> On 24/1/23 6:49 pm, Martin Grigorov wrote:
> On Tue, Jan 24, 2023 at 8:50 AM James Pollard <ja...@iinet.net.au>
> wrote:
>
> I've managed to make some progress with database connectivity, ended up
> using hikaricp instead
>
> HikariCP is a just a connection pool.
> I am not sure what exactly you mean with "instead". A connection pool is
> not a replacement of an ORM framework like Hibernate.
>
>
>
> However, I can't workout where the most appropriate place to put the
> connection pool close call, is there a close or shutdown function
> I can override so that the connection pool can be closed cleanly. I
> haven't had any luck in my search so far
>
> Additionally, I keep running into the following error:
>       java.lang.IllegalStateException: Illegal access: this web
> application instance has been stopped already.
>      Could not load [META-INF/services/org.mariadb.jdbc.plugin.Codec].
> The following stack trace is thrown for debugging purposes as well as to
>      attempt to terminate the thread which caused the illegal access.
>
> I'm assuming this is a error more to do hikaricp so I'll enquire among
> their community about it, but if someone has encountered this before feel
> to volunteer any suggestions or recommended actions. The odd thing is I
> still seem to be able to send queries to the database from what I can
> tell
>
> MyWicketApplication#onDestroy()
> https://github.com/apache/wicket/blob/4affb7b18424e40663239ac9c93d9ec33a432541/wicket-core/src/main/java/org/apache/wicket/Application.java#L569
>
>
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 27/12/22 8:23 am, Vit Rozkovec wrote:
> But I'm not sure where to put the following parts
> Session sess = sessionFactory.openSession();
> ManagedSessionContext.bind(sess);
> This is done in some utility method when you retrieve the session for
> the first time in the request.
>
> You should also check if the session is already bound by calling
>
> ManagedSessionContext.hasBind(SessionFactory factory)
>
> and binding it only once per request.
>
>
> unbindSessionFactory
> I have this in my custom implementation of
> IRequestCycleListener.onEndRequest(RequestCycle cycle)
>
> that you add in Application.init() method
>
> getRequestCycleListeners().add(new DataRequestCycleListener());
>
> To be honest, I've until now stayed away from Spring as it still seems
> to me as a too much of a black box that I didn't find a time to invest
> in learning it, so I may not be the right person to give you advice,
> because my solution may not be the best one either, although it seems
> to be as javadoc of the ManagedSessionContext suggests. The solution I
> now use took heavy inspiration in old old, now nonexistent, Databinder
> that came around the time Wicket 1.2 or so and when I was tasked to
> select new java framework after landing my first job and found Wicket.
> Old times :D.
>
> Vit
>
>
>
> Thank you for the help so far both of you, I've probably made
> mistakes with implement parts
> of the previously outlined process.
> I've come from experimenting with javafx so wicket has been a radical
> change of direction for me
> so far. But since there is very little in the way of examples for
> database integration I'm struggling
> to get my head around how to implement it correctly, as well as
> knowing for sure whether I've
> done it correctly
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
> Hi James,
>
> On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au>
> wrote:
>
> Thanks for the guidance so far, that pointed me to find additional
> resources on JPA
> I believe I have this configured correctly, but I'm confused about how
> to integrate JPA/Hibernate into a
> pure wicket authenticated web application project since the
> resource you
> directed me to previously
> seems to be more heavily on the spring side of things.
>
> This is true. I have used Hibernate/JPA without the SpringBoot
> parts... But
> those projects are private: some owned by me, others no.
>
>
> Thank you for accommodating all my questions and misunderstandings so
> far, I tend to use a reverse
> engineer learning style so it's helped me immensely.
>
> Glad to be of some help. This is why this place is for.
> I've included screenshots of the project file list and the application
> class in the hopes that it makes
>
> They didn't
>
>
> understanding what I'm trying to convey easier
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
>
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
> This defines a JPA entity.... and this JPA/Hibernate
>
>
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
> Project uses Spring magic I guess and will start a Hibernate with H2.
> Wicket is also started via SpringBoot.
>
>
> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
> wrote:
> I've had a look through it but couldn't find any reference to
> hibernate
> so far, its entirely
> possible that I managed to miss it while I was searching though
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
> Hi,
>
> This project
>
> https://github.com/MarcGiffing/wicket-spring-boot
>
> contains a sample project that integrates with JPA/hibernate.
>
>
> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
> wrote:
> Hi,
> can anyone direct me to any resources on how to integrate
> hibernate
> for
> data persistence?
>
> the closest I've managed to find is
>
>
> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
> but there's still things that are confusing me on how to
> ingrate an
> authenticated application with hibernate
>
> --
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org<ma...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org<ma...@wicket.apache.org>
>
> [EXTERNAL EMAIL] CAUTION: This email originated from outside of Telenav. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by "Locke, Jonathan (Luo Shibo)" <jo...@telenav.com>.
JOOQ is good for me most of the time.

Jon

On Jan 24, 2023, at 6:34 PM, James Pollard <ja...@iinet.net.au> wrote:

I don't need hibernates added level of abstraction

I was taught in the past to do database connectivity using jdbc
drivers/connectors, hikaricp just takes this a step further
by providing a pool of connections to use. Basically I've looked at orm
frameworks in the past and just couldn't get my
head around how to use it, I much prefer spelling out my query exactly
myself.

Best Regards
James Pollard
james.pollard@iinet.net.au<ma...@iinet.net.au>

On 24/1/23 6:49 pm, Martin Grigorov wrote:
On Tue, Jan 24, 2023 at 8:50 AM James Pollard <ja...@iinet.net.au>
wrote:

I've managed to make some progress with database connectivity, ended up
using hikaricp instead

HikariCP is a just a connection pool.
I am not sure what exactly you mean with "instead". A connection pool is
not a replacement of an ORM framework like Hibernate.



However, I can't workout where the most appropriate place to put the
connection pool close call, is there a close or shutdown function
I can override so that the connection pool can be closed cleanly. I
haven't had any luck in my search so far

Additionally, I keep running into the following error:
     java.lang.IllegalStateException: Illegal access: this web
application instance has been stopped already.
    Could not load [META-INF/services/org.mariadb.jdbc.plugin.Codec].
The following stack trace is thrown for debugging purposes as well as to
    attempt to terminate the thread which caused the illegal access.

I'm assuming this is a error more to do hikaricp so I'll enquire among
their community about it, but if someone has encountered this before feel
to volunteer any suggestions or recommended actions. The odd thing is I
still seem to be able to send queries to the database from what I can
tell

MyWicketApplication#onDestroy()
https://github.com/apache/wicket/blob/4affb7b18424e40663239ac9c93d9ec33a432541/wicket-core/src/main/java/org/apache/wicket/Application.java#L569



Best Regards
James Pollard
james.pollard@iinet.net.au

On 27/12/22 8:23 am, Vit Rozkovec wrote:
But I'm not sure where to put the following parts
Session sess = sessionFactory.openSession();
ManagedSessionContext.bind(sess);
This is done in some utility method when you retrieve the session for
the first time in the request.

You should also check if the session is already bound by calling

ManagedSessionContext.hasBind(SessionFactory factory)

and binding it only once per request.


unbindSessionFactory
I have this in my custom implementation of
IRequestCycleListener.onEndRequest(RequestCycle cycle)

that you add in Application.init() method

getRequestCycleListeners().add(new DataRequestCycleListener());

To be honest, I've until now stayed away from Spring as it still seems
to me as a too much of a black box that I didn't find a time to invest
in learning it, so I may not be the right person to give you advice,
because my solution may not be the best one either, although it seems
to be as javadoc of the ManagedSessionContext suggests. The solution I
now use took heavy inspiration in old old, now nonexistent, Databinder
that came around the time Wicket 1.2 or so and when I was tasked to
select new java framework after landing my first job and found Wicket.
Old times :D.

Vit



Thank you for the help so far both of you, I've probably made
mistakes with implement parts
of the previously outlined process.
I've come from experimenting with javafx so wicket has been a radical
change of direction for me
so far. But since there is very little in the way of examples for
database integration I'm struggling
to get my head around how to implement it correctly, as well as
knowing for sure whether I've
done it correctly

Best Regards
James Pollard
james.pollard@iinet.net.au

On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
Hi James,

On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au>
wrote:

Thanks for the guidance so far, that pointed me to find additional
resources on JPA
I believe I have this configured correctly, but I'm confused about how
to integrate JPA/Hibernate into a
pure wicket authenticated web application project since the
resource you
directed me to previously
seems to be more heavily on the spring side of things.

This is true. I have used Hibernate/JPA without the SpringBoot
parts... But
those projects are private: some owned by me, others no.


Thank you for accommodating all my questions and misunderstandings so
far, I tend to use a reverse
engineer learning style so it's helped me immensely.

Glad to be of some help. This is why this place is for.
I've included screenshots of the project file list and the application
class in the hopes that it makes

They didn't


understanding what I'm trying to convey easier

Best Regards
James Pollard
james.pollard@iinet.net.au

On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:

https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
This defines a JPA entity.... and this JPA/Hibernate


https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
Project uses Spring magic I guess and will start a Hibernate with H2.
Wicket is also started via SpringBoot.


On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
wrote:
I've had a look through it but couldn't find any reference to
hibernate
so far, its entirely
possible that I managed to miss it while I was searching though

Best Regards
James Pollard
james.pollard@iinet.net.au

On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
Hi,

This project

https://github.com/MarcGiffing/wicket-spring-boot

contains a sample project that integrates with JPA/hibernate.


On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
wrote:
Hi,
can anyone direct me to any resources on how to integrate
hibernate
for
data persistence?

the closest I've managed to find is


https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
but there's still things that are confusing me on how to
ingrate an
authenticated application with hibernate

--
Best Regards
James Pollard
james.pollard@iinet.net.au



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org<ma...@wicket.apache.org>
For additional commands, e-mail: users-help@wicket.apache.org<ma...@wicket.apache.org>

[EXTERNAL EMAIL] CAUTION: This email originated from outside of Telenav. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.


Re: data persistence using hibernate

Posted by James Pollard <ja...@iinet.net.au>.
I don't need hibernates added level of abstraction

I was taught in the past to do database connectivity using jdbc 
drivers/connectors, hikaricp just takes this a step further
by providing a pool of connections to use. Basically I've looked at orm 
frameworks in the past and just couldn't get my
head around how to use it, I much prefer spelling out my query exactly 
myself.

Best Regards
James Pollard
james.pollard@iinet.net.au

On 24/1/23 6:49 pm, Martin Grigorov wrote:
> On Tue, Jan 24, 2023 at 8:50 AM James Pollard <ja...@iinet.net.au>
> wrote:
>
>> I've managed to make some progress with database connectivity, ended up
>> using hikaricp instead
>>
> HikariCP is a just a connection pool.
> I am not sure what exactly you mean with "instead". A connection pool is
> not a replacement of an ORM framework like Hibernate.
>
>
>
>> However, I can't workout where the most appropriate place to put the
>> connection pool close call, is there a close or shutdown function
>> I can override so that the connection pool can be closed cleanly. I
>> haven't had any luck in my search so far
>>
>> Additionally, I keep running into the following error:
>>       java.lang.IllegalStateException: Illegal access: this web
>> application instance has been stopped already.
>>      Could not load [META-INF/services/org.mariadb.jdbc.plugin.Codec].
>> The following stack trace is thrown for debugging purposes as well as to
>>      attempt to terminate the thread which caused the illegal access.
>>
>> I'm assuming this is a error more to do hikaricp so I'll enquire among
>> their community about it, but if someone has encountered this before feel
>> to volunteer any suggestions or recommended actions. The odd thing is I
>> still seem to be able to send queries to the database from what I can
>> tell
>>
> MyWicketApplication#onDestroy()
> https://github.com/apache/wicket/blob/4affb7b18424e40663239ac9c93d9ec33a432541/wicket-core/src/main/java/org/apache/wicket/Application.java#L569
>
>
>
>> Best Regards
>> James Pollard
>> james.pollard@iinet.net.au
>>
>> On 27/12/22 8:23 am, Vit Rozkovec wrote:
>>>> But I'm not sure where to put the following parts
>>>> Session sess = sessionFactory.openSession();
>>>> ManagedSessionContext.bind(sess);
>>> This is done in some utility method when you retrieve the session for
>>> the first time in the request.
>>>
>>> You should also check if the session is already bound by calling
>>>
>>> ManagedSessionContext.hasBind(SessionFactory factory)
>>>
>>> and binding it only once per request.
>>>
>>>
>>>> unbindSessionFactory
>>> I have this in my custom implementation of
>>> IRequestCycleListener.onEndRequest(RequestCycle cycle)
>>>
>>> that you add in Application.init() method
>>>
>>> getRequestCycleListeners().add(new DataRequestCycleListener());
>>>
>>> To be honest, I've until now stayed away from Spring as it still seems
>>> to me as a too much of a black box that I didn't find a time to invest
>>> in learning it, so I may not be the right person to give you advice,
>>> because my solution may not be the best one either, although it seems
>>> to be as javadoc of the ManagedSessionContext suggests. The solution I
>>> now use took heavy inspiration in old old, now nonexistent, Databinder
>>> that came around the time Wicket 1.2 or so and when I was tasked to
>>> select new java framework after landing my first job and found Wicket.
>>> Old times :D.
>>>
>>> Vit
>>>
>>>
>>>>
>>>> Thank you for the help so far both of you, I've probably made
>>>> mistakes with implement parts
>>>> of the previously outlined process.
>>>> I've come from experimenting with javafx so wicket has been a radical
>>>> change of direction for me
>>>> so far. But since there is very little in the way of examples for
>>>> database integration I'm struggling
>>>> to get my head around how to implement it correctly, as well as
>>>> knowing for sure whether I've
>>>> done it correctly
>>>>
>>>> Best Regards
>>>> James Pollard
>>>> james.pollard@iinet.net.au
>>>>
>>>> On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
>>>>> Hi James,
>>>>>
>>>>> On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au>
>>>>> wrote:
>>>>>
>>>>>> Thanks for the guidance so far, that pointed me to find additional
>>>>>> resources on JPA
>>>>>> I believe I have this configured correctly, but I'm confused about how
>>>>>> to integrate JPA/Hibernate into a
>>>>>> pure wicket authenticated web application project since the
>>>>>> resource you
>>>>>> directed me to previously
>>>>>> seems to be more heavily on the spring side of things.
>>>>>>
>>>>> This is true. I have used Hibernate/JPA without the SpringBoot
>>>>> parts... But
>>>>> those projects are private: some owned by me, others no.
>>>>>
>>>>>
>>>>>> Thank you for accommodating all my questions and misunderstandings so
>>>>>> far, I tend to use a reverse
>>>>>> engineer learning style so it's helped me immensely.
>>>>>>
>>>>>> Glad to be of some help. This is why this place is for.
>>>>>> I've included screenshots of the project file list and the application
>>>>>> class in the hopes that it makes
>>>>>>
>>>>> They didn't
>>>>>
>>>>>
>>>>>> understanding what I'm trying to convey easier
>>>>>>
>>>>>> Best Regards
>>>>>> James Pollard
>>>>>> james.pollard@iinet.net.au
>>>>>>
>>>>>> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
>>>>>>
>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
>>>>>>> This defines a JPA entity.... and this JPA/Hibernate
>>>>>>>
>>>>>>>
>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
>>>>>>> Project uses Spring magic I guess and will start a Hibernate with H2.
>>>>>>> Wicket is also started via SpringBoot.
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
>>>>>> wrote:
>>>>>>>> I've had a look through it but couldn't find any reference to
>>>>>>>> hibernate
>>>>>>>> so far, its entirely
>>>>>>>> possible that I managed to miss it while I was searching though
>>>>>>>>
>>>>>>>> Best Regards
>>>>>>>> James Pollard
>>>>>>>> james.pollard@iinet.net.au
>>>>>>>>
>>>>>>>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> This project
>>>>>>>>>
>>>>>>>>> https://github.com/MarcGiffing/wicket-spring-boot
>>>>>>>>>
>>>>>>>>> contains a sample project that integrates with JPA/hibernate.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>> can anyone direct me to any resources on how to integrate
>>>>>>>>>> hibernate
>>>>>> for
>>>>>>>>>> data persistence?
>>>>>>>>>>
>>>>>>>>>> the closest I've managed to find is
>>>>>>>>>>
>>>>>>>>>>
>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
>>>>>>>>>> but there's still things that are confusing me on how to
>>>>>>>>>> ingrate an
>>>>>>>>>> authenticated application with hibernate
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Best Regards
>>>>>>>>>> James Pollard
>>>>>>>>>> james.pollard@iinet.net.au
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>
>>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Jan 24, 2023 at 8:50 AM James Pollard <ja...@iinet.net.au>
wrote:

> I've managed to make some progress with database connectivity, ended up
> using hikaricp instead
>

HikariCP is a just a connection pool.
I am not sure what exactly you mean with "instead". A connection pool is
not a replacement of an ORM framework like Hibernate.



>
> However, I can't workout where the most appropriate place to put the
> connection pool close call, is there a close or shutdown function
> I can override so that the connection pool can be closed cleanly. I
> haven't had any luck in my search so far
>
> Additionally, I keep running into the following error:
>      java.lang.IllegalStateException: Illegal access: this web
> application instance has been stopped already.
>     Could not load [META-INF/services/org.mariadb.jdbc.plugin.Codec].
> The following stack trace is thrown for debugging purposes as well as to
>     attempt to terminate the thread which caused the illegal access.
>
> I'm assuming this is a error more to do hikaricp so I'll enquire among
> their community about it, but if someone has encountered this before feel
> to volunteer any suggestions or recommended actions. The odd thing is I
> still seem to be able to send queries to the database from what I can
> tell
>

MyWicketApplication#onDestroy()
https://github.com/apache/wicket/blob/4affb7b18424e40663239ac9c93d9ec33a432541/wicket-core/src/main/java/org/apache/wicket/Application.java#L569



>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 27/12/22 8:23 am, Vit Rozkovec wrote:
> >
> >>
> >> But I'm not sure where to put the following parts
> >> Session sess = sessionFactory.openSession();
> >> ManagedSessionContext.bind(sess);
> >
> > This is done in some utility method when you retrieve the session for
> > the first time in the request.
> >
> > You should also check if the session is already bound by calling
> >
> > ManagedSessionContext.hasBind(SessionFactory factory)
> >
> > and binding it only once per request.
> >
> >
> >>
> >> unbindSessionFactory
> >
> > I have this in my custom implementation of
> > IRequestCycleListener.onEndRequest(RequestCycle cycle)
> >
> > that you add in Application.init() method
> >
> > getRequestCycleListeners().add(new DataRequestCycleListener());
> >
> > To be honest, I've until now stayed away from Spring as it still seems
> > to me as a too much of a black box that I didn't find a time to invest
> > in learning it, so I may not be the right person to give you advice,
> > because my solution may not be the best one either, although it seems
> > to be as javadoc of the ManagedSessionContext suggests. The solution I
> > now use took heavy inspiration in old old, now nonexistent, Databinder
> > that came around the time Wicket 1.2 or so and when I was tasked to
> > select new java framework after landing my first job and found Wicket.
> > Old times :D.
> >
> > Vit
> >
> >
> >>
> >>
> >> Thank you for the help so far both of you, I've probably made
> >> mistakes with implement parts
> >> of the previously outlined process.
> >> I've come from experimenting with javafx so wicket has been a radical
> >> change of direction for me
> >> so far. But since there is very little in the way of examples for
> >> database integration I'm struggling
> >> to get my head around how to implement it correctly, as well as
> >> knowing for sure whether I've
> >> done it correctly
> >>
> >> Best Regards
> >> James Pollard
> >> james.pollard@iinet.net.au
> >>
> >> On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
> >>> Hi James,
> >>>
> >>> On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au>
> >>> wrote:
> >>>
> >>>> Thanks for the guidance so far, that pointed me to find additional
> >>>> resources on JPA
> >>>> I believe I have this configured correctly, but I'm confused about how
> >>>> to integrate JPA/Hibernate into a
> >>>> pure wicket authenticated web application project since the
> >>>> resource you
> >>>> directed me to previously
> >>>> seems to be more heavily on the spring side of things.
> >>>>
> >>> This is true. I have used Hibernate/JPA without the SpringBoot
> >>> parts... But
> >>> those projects are private: some owned by me, others no.
> >>>
> >>>
> >>>> Thank you for accommodating all my questions and misunderstandings so
> >>>> far, I tend to use a reverse
> >>>> engineer learning style so it's helped me immensely.
> >>>>
> >>>> Glad to be of some help. This is why this place is for.
> >>>
> >>>> I've included screenshots of the project file list and the application
> >>>> class in the hopes that it makes
> >>>>
> >>> They didn't
> >>>
> >>>
> >>>> understanding what I'm trying to convey easier
> >>>>
> >>>> Best Regards
> >>>> James Pollard
> >>>> james.pollard@iinet.net.au
> >>>>
> >>>> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
> >>>>
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
> >>>>
> >>>>> This defines a JPA entity.... and this JPA/Hibernate
> >>>>>
> >>>>>
> >>>>
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
> >>>>
> >>>>> Project uses Spring magic I guess and will start a Hibernate with H2.
> >>>>> Wicket is also started via SpringBoot.
> >>>>>
> >>>>>
> >>>>> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
> >>>> wrote:
> >>>>>> I've had a look through it but couldn't find any reference to
> >>>>>> hibernate
> >>>>>> so far, its entirely
> >>>>>> possible that I managed to miss it while I was searching though
> >>>>>>
> >>>>>> Best Regards
> >>>>>> James Pollard
> >>>>>> james.pollard@iinet.net.au
> >>>>>>
> >>>>>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> This project
> >>>>>>>
> >>>>>>> https://github.com/MarcGiffing/wicket-spring-boot
> >>>>>>>
> >>>>>>> contains a sample project that integrates with JPA/hibernate.
> >>>>>>>
> >>>>>>>
> >>>>>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
> >>>>>> wrote:
> >>>>>>>> Hi,
> >>>>>>>> can anyone direct me to any resources on how to integrate
> >>>>>>>> hibernate
> >>>> for
> >>>>>>>> data persistence?
> >>>>>>>>
> >>>>>>>> the closest I've managed to find is
> >>>>>>>>
> >>>>>>>>
> >>>>
> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
> >>>>
> >>>>>>>> but there's still things that are confusing me on how to
> >>>>>>>> ingrate an
> >>>>>>>> authenticated application with hibernate
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Best Regards
> >>>>>>>> James Pollard
> >>>>>>>> james.pollard@iinet.net.au
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>>>
> >>>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: data persistence using hibernate

Posted by James Pollard <ja...@iinet.net.au>.
I've managed to make some progress with database connectivity, ended up 
using hikaricp instead

However, I can't workout where the most appropriate place to put the 
connection pool close call, is there a close or shutdown function
I can override so that the connection pool can be closed cleanly. I 
haven't had any luck in my search so far

Additionally, I keep running into the following error:
     java.lang.IllegalStateException: Illegal access: this web 
application instance has been stopped already.
    Could not load [META-INF/services/org.mariadb.jdbc.plugin.Codec]. 
The following stack trace is thrown for debugging purposes as well as to
    attempt to terminate the thread which caused the illegal access.

I'm assuming this is a error more to do hikaricp so I'll enquire among 
their community about it, but if someone has encountered this before feel
to volunteer any suggestions or recommended actions. The odd thing is I 
still seem to be able to send queries to the database from what I can
tell

Best Regards
James Pollard
james.pollard@iinet.net.au

On 27/12/22 8:23 am, Vit Rozkovec wrote:
>
>>
>> But I'm not sure where to put the following parts
>> Session sess = sessionFactory.openSession();
>> ManagedSessionContext.bind(sess);
>
> This is done in some utility method when you retrieve the session for 
> the first time in the request.
>
> You should also check if the session is already bound by calling
>
> ManagedSessionContext.hasBind(SessionFactory factory)
>
> and binding it only once per request.
>
>
>>
>> unbindSessionFactory
>
> I have this in my custom implementation of 
> IRequestCycleListener.onEndRequest(RequestCycle cycle)
>
> that you add in Application.init() method
>
> getRequestCycleListeners().add(new DataRequestCycleListener());
>
> To be honest, I've until now stayed away from Spring as it still seems 
> to me as a too much of a black box that I didn't find a time to invest 
> in learning it, so I may not be the right person to give you advice, 
> because my solution may not be the best one either, although it seems 
> to be as javadoc of the ManagedSessionContext suggests. The solution I 
> now use took heavy inspiration in old old, now nonexistent, Databinder 
> that came around the time Wicket 1.2 or so and when I was tasked to 
> select new java framework after landing my first job and found Wicket. 
> Old times :D.
>
> Vit
>
>
>>
>>
>> Thank you for the help so far both of you, I've probably made 
>> mistakes with implement parts
>> of the previously outlined process.
>> I've come from experimenting with javafx so wicket has been a radical 
>> change of direction for me
>> so far. But since there is very little in the way of examples for 
>> database integration I'm struggling
>> to get my head around how to implement it correctly, as well as 
>> knowing for sure whether I've
>> done it correctly
>>
>> Best Regards
>> James Pollard
>> james.pollard@iinet.net.au
>>
>> On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
>>> Hi James,
>>>
>>> On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au> 
>>> wrote:
>>>
>>>> Thanks for the guidance so far, that pointed me to find additional
>>>> resources on JPA
>>>> I believe I have this configured correctly, but I'm confused about how
>>>> to integrate JPA/Hibernate into a
>>>> pure wicket authenticated web application project since the 
>>>> resource you
>>>> directed me to previously
>>>> seems to be more heavily on the spring side of things.
>>>>
>>> This is true. I have used Hibernate/JPA without the SpringBoot 
>>> parts... But
>>> those projects are private: some owned by me, others no.
>>>
>>>
>>>> Thank you for accommodating all my questions and misunderstandings so
>>>> far, I tend to use a reverse
>>>> engineer learning style so it's helped me immensely.
>>>>
>>>> Glad to be of some help. This is why this place is for.
>>>
>>>> I've included screenshots of the project file list and the application
>>>> class in the hopes that it makes
>>>>
>>> They didn't
>>>
>>>
>>>> understanding what I'm trying to convey easier
>>>>
>>>> Best Regards
>>>> James Pollard
>>>> james.pollard@iinet.net.au
>>>>
>>>> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
>>>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java 
>>>>
>>>>> This defines a JPA entity.... and this JPA/Hibernate
>>>>>
>>>>>
>>>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml 
>>>>
>>>>> Project uses Spring magic I guess and will start a Hibernate with H2.
>>>>> Wicket is also started via SpringBoot.
>>>>>
>>>>>
>>>>> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
>>>> wrote:
>>>>>> I've had a look through it but couldn't find any reference to 
>>>>>> hibernate
>>>>>> so far, its entirely
>>>>>> possible that I managed to miss it while I was searching though
>>>>>>
>>>>>> Best Regards
>>>>>> James Pollard
>>>>>> james.pollard@iinet.net.au
>>>>>>
>>>>>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> This project
>>>>>>>
>>>>>>> https://github.com/MarcGiffing/wicket-spring-boot
>>>>>>>
>>>>>>> contains a sample project that integrates with JPA/hibernate.
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
>>>>>> wrote:
>>>>>>>> Hi,
>>>>>>>> can anyone direct me to any resources on how to integrate 
>>>>>>>> hibernate
>>>> for
>>>>>>>> data persistence?
>>>>>>>>
>>>>>>>> the closest I've managed to find is
>>>>>>>>
>>>>>>>>
>>>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7 
>>>>
>>>>>>>> but there's still things that are confusing me on how to 
>>>>>>>> ingrate an
>>>>>>>> authenticated application with hibernate
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> Best Regards
>>>>>>>> James Pollard
>>>>>>>> james.pollard@iinet.net.au
>>>>>>>>
>>>>>>>>
>>>>>>>> --------------------------------------------------------------------- 
>>>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by Vit Rozkovec <ro...@email.cz>.
>
> But I'm not sure where to put the following parts
> Session sess = sessionFactory.openSession();
> ManagedSessionContext.bind(sess);

This is done in some utility method when you retrieve the session for 
the first time in the request.

You should also check if the session is already bound by calling

ManagedSessionContext.hasBind(SessionFactory factory)

and binding it only once per request.


>
> unbindSessionFactory

I have this in my custom implementation of 
IRequestCycleListener.onEndRequest(RequestCycle cycle)

that you add in Application.init() method

getRequestCycleListeners().add(new DataRequestCycleListener());

To be honest, I've until now stayed away from Spring as it still seems 
to me as a too much of a black box that I didn't find a time to invest 
in learning it, so I may not be the right person to give you advice, 
because my solution may not be the best one either, although it seems to 
be as javadoc of the ManagedSessionContext suggests. The solution I now 
use took heavy inspiration in old old, now nonexistent, Databinder that 
came around the time Wicket 1.2 or so and when I was tasked to select 
new java framework after landing my first job and found Wicket. Old 
times :D.

Vit


>
>
> Thank you for the help so far both of you, I've probably made mistakes 
> with implement parts
> of the previously outlined process.
> I've come from experimenting with javafx so wicket has been a radical 
> change of direction for me
> so far. But since there is very little in the way of examples for 
> database integration I'm struggling
> to get my head around how to implement it correctly, as well as 
> knowing for sure whether I've
> done it correctly
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
>> Hi James,
>>
>> On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au> 
>> wrote:
>>
>>> Thanks for the guidance so far, that pointed me to find additional
>>> resources on JPA
>>> I believe I have this configured correctly, but I'm confused about how
>>> to integrate JPA/Hibernate into a
>>> pure wicket authenticated web application project since the resource 
>>> you
>>> directed me to previously
>>> seems to be more heavily on the spring side of things.
>>>
>> This is true. I have used Hibernate/JPA without the SpringBoot 
>> parts... But
>> those projects are private: some owned by me, others no.
>>
>>
>>> Thank you for accommodating all my questions and misunderstandings so
>>> far, I tend to use a reverse
>>> engineer learning style so it's helped me immensely.
>>>
>>> Glad to be of some help. This is why this place is for.
>>
>>> I've included screenshots of the project file list and the application
>>> class in the hopes that it makes
>>>
>> They didn't
>>
>>
>>> understanding what I'm trying to convey easier
>>>
>>> Best Regards
>>> James Pollard
>>> james.pollard@iinet.net.au
>>>
>>> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
>>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java 
>>>
>>>> This defines a JPA entity.... and this JPA/Hibernate
>>>>
>>>>
>>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml 
>>>
>>>> Project uses Spring magic I guess and will start a Hibernate with H2.
>>>> Wicket is also started via SpringBoot.
>>>>
>>>>
>>>> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
>>> wrote:
>>>>> I've had a look through it but couldn't find any reference to 
>>>>> hibernate
>>>>> so far, its entirely
>>>>> possible that I managed to miss it while I was searching though
>>>>>
>>>>> Best Regards
>>>>> James Pollard
>>>>> james.pollard@iinet.net.au
>>>>>
>>>>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
>>>>>> Hi,
>>>>>>
>>>>>> This project
>>>>>>
>>>>>> https://github.com/MarcGiffing/wicket-spring-boot
>>>>>>
>>>>>> contains a sample project that integrates with JPA/hibernate.
>>>>>>
>>>>>>
>>>>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
>>>>> wrote:
>>>>>>> Hi,
>>>>>>> can anyone direct me to any resources on how to integrate hibernate
>>> for
>>>>>>> data persistence?
>>>>>>>
>>>>>>> the closest I've managed to find is
>>>>>>>
>>>>>>>
>>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7 
>>>
>>>>>>> but there's still things that are confusing me on how to ingrate an
>>>>>>> authenticated application with hibernate
>>>>>>>
>>>>>>> -- 
>>>>>>> Best Regards
>>>>>>> James Pollard
>>>>>>> james.pollard@iinet.net.au
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by James Pollard <ja...@iinet.net.au>.
Thanks Vit,

I've defined the hibernate.cfg.xml file

I've defined the following globally in the Application class
private Configuration config = new Configuration();
private ServiceRegistry serviceRegistry;
private SessionFactory sessionFactory;

I've placed the following at the end of the init function
config.configure("hibernate.cfg.xml");
config.setProperty("hibernate.current_session_context_class", "managed");
serviceRegistry = new 
StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();
sessionFactory = config.buildSessionFactory(serviceRegistry);

But I'm not sure where to put the following parts
Session sess = sessionFactory.openSession();
ManagedSessionContext.bind(sess);

unbindSessionFactory


Thank you for the help so far both of you, I've probably made mistakes 
with implement parts
of the previously outlined process.
I've come from experimenting with javafx so wicket has been a radical 
change of direction for me
so far. But since there is very little in the way of examples for 
database integration I'm struggling
to get my head around how to implement it correctly, as well as knowing 
for sure whether I've
done it correctly

Best Regards
James Pollard
james.pollard@iinet.net.au

On 23/12/22 10:16 am, Ernesto Reinaldo Barreiro wrote:
> Hi James,
>
> On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au> wrote:
>
>> Thanks for the guidance so far, that pointed me to find additional
>> resources on JPA
>> I believe I have this configured correctly, but I'm confused about how
>> to integrate JPA/Hibernate into a
>> pure wicket authenticated web application project since the resource you
>> directed me to previously
>> seems to be more heavily on the spring side of things.
>>
> This is true. I have used Hibernate/JPA without the SpringBoot parts... But
> those projects are private: some owned by me, others no.
>
>
>> Thank you for accommodating all my questions and misunderstandings so
>> far, I tend to use a reverse
>> engineer learning style so it's helped me immensely.
>>
>> Glad to be of some help. This is why this place is for.
>
>> I've included screenshots of the project file list and the application
>> class in the hopes that it makes
>>
> They didn't
>
>
>> understanding what I'm trying to convey easier
>>
>> Best Regards
>> James Pollard
>> james.pollard@iinet.net.au
>>
>> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
>>> This defines a JPA entity.... and this JPA/Hibernate
>>>
>>>
>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
>>> Project uses Spring magic I guess and will start a Hibernate with H2.
>>> Wicket is also started via SpringBoot.
>>>
>>>
>>> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
>> wrote:
>>>> I've had a look through it but couldn't find any reference to hibernate
>>>> so far, its entirely
>>>> possible that I managed to miss it while I was searching though
>>>>
>>>> Best Regards
>>>> James Pollard
>>>> james.pollard@iinet.net.au
>>>>
>>>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
>>>>> Hi,
>>>>>
>>>>> This project
>>>>>
>>>>> https://github.com/MarcGiffing/wicket-spring-boot
>>>>>
>>>>> contains a sample project that integrates with JPA/hibernate.
>>>>>
>>>>>
>>>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
>>>> wrote:
>>>>>> Hi,
>>>>>> can anyone direct me to any resources on how to integrate hibernate
>> for
>>>>>> data persistence?
>>>>>>
>>>>>> the closest I've managed to find is
>>>>>>
>>>>>>
>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
>>>>>> but there's still things that are confusing me on how to ingrate an
>>>>>> authenticated application with hibernate
>>>>>>
>>>>>> --
>>>>>> Best Regards
>>>>>> James Pollard
>>>>>> james.pollard@iinet.net.au
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi James,

On Thu, Dec 22, 2022 at 2:24 PM James <ja...@iinet.net.au> wrote:

> Thanks for the guidance so far, that pointed me to find additional
> resources on JPA
> I believe I have this configured correctly, but I'm confused about how
> to integrate JPA/Hibernate into a
> pure wicket authenticated web application project since the resource you
> directed me to previously
> seems to be more heavily on the spring side of things.
>

This is true. I have used Hibernate/JPA without the SpringBoot parts... But
those projects are private: some owned by me, others no.


> Thank you for accommodating all my questions and misunderstandings so
> far, I tend to use a reverse
> engineer learning style so it's helped me immensely.
>
> Glad to be of some help. This is why this place is for.


> I've included screenshots of the project file list and the application
> class in the hopes that it makes
>
They didn't


> understanding what I'm trying to convey easier
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
> >
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
> >
> > This defines a JPA entity.... and this JPA/Hibernate
> >
> >
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
> >
> > Project uses Spring magic I guess and will start a Hibernate with H2.
> > Wicket is also started via SpringBoot.
> >
> >
> > On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au>
> wrote:
> >
> >> I've had a look through it but couldn't find any reference to hibernate
> >> so far, its entirely
> >> possible that I managed to miss it while I was searching though
> >>
> >> Best Regards
> >> James Pollard
> >> james.pollard@iinet.net.au
> >>
> >> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
> >>> Hi,
> >>>
> >>> This project
> >>>
> >>> https://github.com/MarcGiffing/wicket-spring-boot
> >>>
> >>> contains a sample project that integrates with JPA/hibernate.
> >>>
> >>>
> >>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
> >> wrote:
> >>>> Hi,
> >>>> can anyone direct me to any resources on how to integrate hibernate
> for
> >>>> data persistence?
> >>>>
> >>>> the closest I've managed to find is
> >>>>
> >>>>
> >>
> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
> >>>> but there's still things that are confusing me on how to ingrate an
> >>>> authenticated application with hibernate
> >>>>
> >>>> --
> >>>> Best Regards
> >>>> James Pollard
> >>>> james.pollard@iinet.net.au
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>
> >>>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org



-- 
Regards - Ernesto Reinaldo Barreiro

Re: data persistence using hibernate

Posted by Vit Rozkovec <ro...@email.cz>.
Hi,

I'm currently using Hibernate without Spring and what you want to 
achieve can be done in several steps:

- prepare your org.hibernate.cfg.Configuration
- set Configuration's property: 
config.setProperty("hibernate.current_session_context_class", "managed");
- get SessionFactory by caling org.hibernate.cfg.Configuration.build()
- store SessionFactory's instance somewhere and keep it for the duration 
of your application
- when you request a session, bind it:
Session sess = sessionFactory.openSession();
ManagedSessionContext.bind(sess);

- at the end of request cycle, unbind SessionFactory. Implement your own 
IRequestCycleListener and in IRequestCycleListener.onEndRequest call 
unbind logic.
Here's what I use:

public void unbindSessionFactory(Object key, boolean closeSessionFactory)
     {
         SessionFactory sf = getHibernateSessionFactory(key);

         if (hasBoundSession(sf))
         {
             Session sess = sf.getCurrentSession();

             if (sess.isOpen())
             {
                 try
                 {
                     if (sess.getTransaction().isActive())
                     {
                         sess.getTransaction().rollback();
                     }
                 }
                 finally
                 {
                     sess.close();
                 }
             }

             ManagedSessionContext.unbind(sf);

             if (closeSessionFactory)
                 sf.close();
         }
     }

- when application exits, close session factory

Hope that helped.

Vit



On 22. 12. 22 8:23, James wrote:
> Thanks for the guidance so far, that pointed me to find additional 
> resources on JPA
> I believe I have this configured correctly, but I'm confused about how 
> to integrate JPA/Hibernate into a
> pure wicket authenticated web application project since the resource 
> you directed me to previously
> seems to be more heavily on the spring side of things.
>
> Thank you for accommodating all my questions and misunderstandings so 
> far, I tend to use a reverse
> engineer learning style so it's helped me immensely.
>
> I've included screenshots of the project file list and the application 
> class in the hopes that it makes
> understanding what I'm trying to convey easier
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java 
>>
>>
>> This defines a JPA entity.... and this JPA/Hibernate
>>
>> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml 
>>
>>
>> Project uses Spring magic I guess and will start a Hibernate with H2.
>> Wicket is also started via SpringBoot.
>>
>>
>> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au> 
>> wrote:
>>
>>> I've had a look through it but couldn't find any reference to hibernate
>>> so far, its entirely
>>> possible that I managed to miss it while I was searching though
>>>
>>> Best Regards
>>> James Pollard
>>> james.pollard@iinet.net.au
>>>
>>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
>>>> Hi,
>>>>
>>>> This project
>>>>
>>>> https://github.com/MarcGiffing/wicket-spring-boot
>>>>
>>>> contains a sample project that integrates with JPA/hibernate.
>>>>
>>>>
>>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
>>> wrote:
>>>>> Hi,
>>>>> can anyone direct me to any resources on how to integrate 
>>>>> hibernate for
>>>>> data persistence?
>>>>>
>>>>> the closest I've managed to find is
>>>>>
>>>>>
>>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7 
>>>
>>>>> but there's still things that are confusing me on how to ingrate an
>>>>> authenticated application with hibernate
>>>>>
>>>>> -- 
>>>>> Best Regards
>>>>> James Pollard
>>>>> james.pollard@iinet.net.au
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by James <ja...@iinet.net.au>.
Thanks for the guidance so far, that pointed me to find additional 
resources on JPA
I believe I have this configured correctly, but I'm confused about how 
to integrate JPA/Hibernate into a
pure wicket authenticated web application project since the resource you 
directed me to previously
seems to be more heavily on the spring side of things.

Thank you for accommodating all my questions and misunderstandings so 
far, I tend to use a reverse
engineer learning style so it's helped me immensely.

I've included screenshots of the project file list and the application 
class in the hopes that it makes
understanding what I'm trying to convey easier

Best Regards
James Pollard
james.pollard@iinet.net.au

On 20/12/22 12:58 pm, Ernesto Reinaldo Barreiro wrote:
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java
>
> This defines a JPA entity.... and this JPA/Hibernate
>
> https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml
>
> Project uses Spring magic I guess and will start a Hibernate with H2.
> Wicket is also started via SpringBoot.
>
>
> On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au> wrote:
>
>> I've had a look through it but couldn't find any reference to hibernate
>> so far, its entirely
>> possible that I managed to miss it while I was searching though
>>
>> Best Regards
>> James Pollard
>> james.pollard@iinet.net.au
>>
>> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
>>> Hi,
>>>
>>> This project
>>>
>>> https://github.com/MarcGiffing/wicket-spring-boot
>>>
>>> contains a sample project that integrates with JPA/hibernate.
>>>
>>>
>>> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
>> wrote:
>>>> Hi,
>>>> can anyone direct me to any resources on how to integrate hibernate for
>>>> data persistence?
>>>>
>>>> the closest I've managed to find is
>>>>
>>>>
>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
>>>> but there's still things that are confusing me on how to ingrate an
>>>> authenticated application with hibernate
>>>>
>>>> --
>>>> Best Regards
>>>> James Pollard
>>>> james.pollard@iinet.net.au
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


Re: data persistence using hibernate

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java

This defines a JPA entity.... and this JPA/Hibernate

https://github.com/MarcGiffing/wicket-spring-boot/blob/master/wicket-spring-boot-starter-example/src/main/resources/application.yml

Project uses Spring magic I guess and will start a Hibernate with H2.
Wicket is also started via SpringBoot.


On Tue, Dec 20, 2022 at 7:44 AM James <ja...@iinet.net.au> wrote:

> I've had a look through it but couldn't find any reference to hibernate
> so far, its entirely
> possible that I managed to miss it while I was searching though
>
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
> On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
> > Hi,
> >
> > This project
> >
> > https://github.com/MarcGiffing/wicket-spring-boot
> >
> > contains a sample project that integrates with JPA/hibernate.
> >
> >
> > On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au>
> wrote:
> >
> >> Hi,
> >> can anyone direct me to any resources on how to integrate hibernate for
> >> data persistence?
> >>
> >> the closest I've managed to find is
> >>
> >>
> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
> >> but there's still things that are confusing me on how to ingrate an
> >> authenticated application with hibernate
> >>
> >> --
> >> Best Regards
> >> James Pollard
> >> james.pollard@iinet.net.au
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

-- 
Regards - Ernesto Reinaldo Barreiro

Re: data persistence using hibernate

Posted by James <ja...@iinet.net.au>.
I've had a look through it but couldn't find any reference to hibernate 
so far, its entirely
possible that I managed to miss it while I was searching though

Best Regards
James Pollard
james.pollard@iinet.net.au

On 19/12/22 5:06 pm, Ernesto Reinaldo Barreiro wrote:
> Hi,
>
> This project
>
> https://github.com/MarcGiffing/wicket-spring-boot
>
> contains a sample project that integrates with JPA/hibernate.
>
>
> On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au> wrote:
>
>> Hi,
>> can anyone direct me to any resources on how to integrate hibernate for
>> data persistence?
>>
>> the closest I've managed to find is
>>
>> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
>> but there's still things that are confusing me on how to ingrate an
>> authenticated application with hibernate
>>
>> --
>> Best Regards
>> James Pollard
>> james.pollard@iinet.net.au
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: data persistence using hibernate

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,

This project

https://github.com/MarcGiffing/wicket-spring-boot

contains a sample project that integrates with JPA/hibernate.


On Mon, Dec 19, 2022 at 9:12 AM James <ja...@iinet.net.au> wrote:

> Hi,
> can anyone direct me to any resources on how to integrate hibernate for
> data persistence?
>
> the closest I've managed to find is
>
> https://www.infoworld.com/article/2077901/web-development-with-wicket--part-3--many-ways-to-persist.html?page=7
> but there's still things that are confusing me on how to ingrate an
> authenticated application with hibernate
>
> --
> Best Regards
> James Pollard
> james.pollard@iinet.net.au
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

-- 
Regards - Ernesto Reinaldo Barreiro