Comments (9)
Hi @brunnels. Thanks for raising the issue. That doesn't surprise me. The current JPA module is a little bit of a POC. However, we are wrapping up a major revision that takes the same approach as Spring Batch with platform-specific .SQL files and Spring Batch auto-configuration that picks and runs the right set of .SQL files.
This sounds pretty close/almost exactly what u need. Would u be willing to test/contribute .SQL files for SQL Server?
from spring-content.
Sure. Just point me at the branch and I can send a merge request.
from spring-content.
Great. Give me a day or two to pull it together and push the latest of the feature branch and I'll ping you here. Thanks
from spring-content.
Hey @brunnels I have pushed a "work in progress" on the wip/jpa-resource branch. It isn't particularly clean (in terms of test-driven) but it has been manually tested against mysql and postgres.
The way the JPA module is now intended to work is the same as Spring Batch (another Spring library that requires schema initialization). When using the JPA module the developer will have to supply the DataSource bean (as he always has) and also a DataSourceInitializer bean to initialize the given DataSource with the relevant Spring Content schema. In this case the DataSourceInitializer would look like this:-
@Value("/org/springframework/content/jpa/schema-drop-postgresql.sql")
private Resource dropReopsitoryTables;
@Value("/org/springframework/content/jpa/schema-postgresql.sql")
private Resource dataReopsitorySchema;
@Bean
public DataSource dataSource() {
...
return ds;
}
@Bean
DataSourceInitializer datasourceInitializer() {
ResourceDatabasePopulator databasePopulator =
new ResourceDatabasePopulator();
databasePopulator.addScript(dropReopsitoryTables);
databasePopulator.addScript(dataReopsitorySchema);
databasePopulator.setIgnoreFailedDrops(true);
DataSourceInitializer initializer = new DataSourceInitializer();
initializer.setDataSource(dataSource());
initializer.setDatabasePopulator(databasePopulator);
return initializer;
}
entity transaction manager beans ommitted for brevity
I have (manually) tested this using the example/integration project spring-eg-content-jpa by hacking up the configuration to provide the new datasourecinitializer bean.
Point to note that when using the boot starter for Spring Content for JPA this datasource initialization will eventually be auto-configured. This is still to be done BTW so don't expect it to work.
I also refactored the central DefaultJPAStoreImpl class to use a new (Blob)Resource abstraction based on the standard Spring Resource interface (this is actually part of a broader experimental Store API piece of work). This is where the relevant SQL will be executed as content is set, updated and unset (see AbstractBlobResource). There is a possibility that the hardcoded SQL statements wont work on SQLServer and if that is the case we should first take a look at whether we have done anything non-standard in the SQL, or not. Possibly the case. But I am also finding that the various drivers don't support the full compliment of JDBC API and we may be forced to have database-specific blob resource implementations. In a previous incantation of this changed I had actually paved the way for this so I left that code in just in case we need it. See DelegatingBlobResourceLoader and AbstractBblobResource. Feel free to use it if you feel that you need to. However, if we don't end up using it then we can decide later on whether to leave it in, or rip it out. This can of plug-in capability can often useful and can get someone of out trouble in a pinch. But maybe it is more hassle than it is worth.
So I think you can use this to test against SQLServer by adding a the relevant .sql files and adding the DataSourceInitializer bean to your project then set, updating and unsettting content. feel free to post back here with anything that you do find.
In the meantime, I will clean this all up, go find various free hosting options to perform accepting testing against and add the spring boot starter auto-configuration.
from spring-content.
Hi @brunnels I just committed changes to support sql server on wip/jpa-resource. Our integration tests work but aren't committed yet). Please feel free to give this branch a go but I will try and wrap this up and merge it across to master soonest whereby it will be available in the latest snapshot.
from spring-content.
from spring-content.
No problem. I know how it is. When you get a chance let me know how it goes.
from spring-content.
I rebased this work onto master this evening so it is available on the latest 0.0.10-SNAPSHOT. Might make it a bit easier to consume for you.
from spring-content.
This fix went out in 0.0.10 (released today). I am going to close this but feel free to re-open or open any new issues should you run into anything. We are running our standard acceptance tests against SQL Server so I think the basics should be there for you.
from spring-content.
Related Issues (20)
- S3ContentStore, FilesystemContentStore, etc extend deprecated ContentStore HOT 2
- spring-content-fs depends on old version of Hibernate
- Fail to set content on nested content properties when using JPA. HOT 2
- @ContentLength field is set to 0 instead of null for nullable types
- POST to content-property without content-type results in NPE / HTTP-500 HOT 1
- Link relation and path configured with @RestResource ignored for content properties with multiple capital letters HOT 1
- Do not include junit as compile dependency
- Exception with unsetContent using SB3 and SC3.0.4 JPA Starter HOT 1
- File download not working on windows platform HOT 1
- How do I configure com.github.paulcwarren:spring-content-bom for spring boot kotlin gradle? HOT 1
- Hibernate dependency error HOT 4
- No suitable HttpMessageConverter found to read request body into object of type class com.example.demo.entity.client.image.Avatar from request with content type of image/png;charset=UTF-8 HOT 8
- Investigation into the cause of `java.lang.NullPointerException: Cannot invoke "org.springframework.content.commons.storeservice.StoreInfo.getInterface()" because the return value of "internal.org.springframework.content.rest.io.StoreResource.getStoreInfo()" is null`
- Maven build error with Graal VM on Spring Content HOT 4
- Crash when use FileSystemResourceLoader in the latest version of spring boot HOT 1
- Not compatible with Spring Boot 3.2: method Assert.notNull(Object) does not exist HOT 2
- If-Match HTTP header gets ignored by a concurrent PUT after DELETE on the content of an entity HOT 1
- Filesize and filename are not set after a multipart/form POST http request to create entity with content HOT 1
- Events emitted twice HOT 2
- Relation "Blobs" not found HOT 2
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 spring-content.