Comments (4)
As mentioned in http://gorm.grails.org/6.0.x/hibernate/manual/index.html#outsideGrails you need to declare the necessary dependencies. The dependencies that are not in the example you have that are mentioned as being necessary in the docs are the connection pool to use:
runtime "org.apache.tomcat:tomcat-jdbc:8.5.0"
runtime "org.apache.tomcat.embed:tomcat-embed-logging-log4j:8.5.0"
The connection pool can be commons-dbcp, tomcat pool or hikari. If you don't specify a connection pool then a org.springframework.jdbc.datasource.DriverManagerDataSource
is used, which creates a new connection to the database each time you request a connect.
The problem with this when you use an in-memory database is that h2 is creating a new in-memory database each time a connection is requested. So the tables that were created previously are lost. If you were using a normal database (mysql, postgres or h2 file based database) your example would work fine.
It is the combination of DriverManagerDataSource
, which creates and initialises a brand new in-memory database each time a connection is requested (because it is not a pool), and h2 in-memory that causes the issue you are seeing.
That is why we include a connection pool in the list of necessary dependencies, since people are likely to stumble into this (as you have) and also any real production application would use a pool.
from gorm-hibernate5.
RIght. I'm going to create a PR which describes this a bit better in the docs.
from gorm-hibernate5.
On that note of docs isn't the use of implements GormEntity<Person>
redundant? I thought @Entity
effectively does that.
from gorm-hibernate5.
It is, but some IDEs use the fact that the class is in grails-app/domain
to enable code completion. So by being explicit about implementing the trait you are more likely to obtain completions etc.
from gorm-hibernate5.
Related Issues (20)
- Trivial: typos in GormEntity.groovy
- Domain Merge does not flush dirty fields to datastore HOT 2
- Make 'org.grails.orm.hibernate.GrailsSessionContext.allowCreate' configurable HOT 2
- When validating domain object, default dataSource sessionFactory is used instead of defined one. HOT 3
- Domain subclass does not inherit caching from parent HOT 1
- No Session found for current thread in spring boot test HOT 2
- Second level cache (still?) not working for inherited domains HOT 11
- Using size() for collection associations in where-queries or detached criteria leads to exception
- Domain class mapping with `fetch: 'join'` on OneToOne association results in n+1 queries HOT 2
- how to support springboot 3.x ? HOT 3
- Release 8.0.0 depends on grailsVersion 6.0.0-SNAPSHOT HOT 1
- Multitenant - Discriminator - @CurrentTenant not honored if session created by SessionFactory.currentSession HOT 4
- application.groovy in standalone mode is not read HOT 9
- Section 5.4.2 strange index operator <<0>>
- Spring @Transactional not applied for GORM methods in java HOT 1
- Error when running application NoClassDef jakarta/persistance/EntityManager HOT 9
- when will release 9.0.x alpha version? HOT 2
- No GORM implementations configured. Ensure GORM has been initialized correctly
- Can I dynamically register a domain? HOT 12
- BuildableCriteria#list can not cast results to org.grails.orm.hibernate.query.PagedResultList
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gorm-hibernate5.