Giter Club home page Giter Club logo

Comments (9)

paulcwarren avatar paulcwarren commented on May 14, 2024

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.

brunnels avatar brunnels commented on May 14, 2024

Sure. Just point me at the branch and I can send a merge request.

from spring-content.

paulcwarren avatar paulcwarren commented on May 14, 2024

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.

paulcwarren avatar paulcwarren commented on May 14, 2024

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.

paulcwarren avatar paulcwarren commented on May 14, 2024

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.

brunnels avatar brunnels commented on May 14, 2024

from spring-content.

paulcwarren avatar paulcwarren commented on May 14, 2024

No problem. I know how it is. When you get a chance let me know how it goes.

from spring-content.

paulcwarren avatar paulcwarren commented on May 14, 2024

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.

paulcwarren avatar paulcwarren commented on May 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.