Git Product home page Git Product logo

Comments (2)

paulcwarren avatar paulcwarren commented on June 13, 2024

Thanks @vierbergenlars . I see what you are asking for. I think I would have to make it configurable so I need to look into how best to do that (given its depth in the architecture).

Just curious on your opinion in general. I think this can be easily solved in the application later with an @PostLoad annotation on Person; i.e:

	@PostLoad
	private void initData() {
		if(picT == null) {
			picT = new Content();
		}
	}

Would that work for you all? Or are there reasons/justifications why that wouldn't work (well) beyond keeping the app model simple?

from spring-content.

vierbergenlars avatar vierbergenlars commented on June 13, 2024

Putting some code in @PostLoad would work, but I consider that a workaround for this bug.

Although it's perhaps a small detail, the response provided by spring-data-rest would also be impacted, instead of looking like I would expect, we will have an object with all null fields when there is no content.

ExpectedActual
{
  "id": "830ccc3d-5131-4285-b462-2f0995e5f492",
  "name": "xyz",
  "picture": null
}
{
  "id": "830ccc3d-5131-4285-b462-2f0995e5f492",
  "name": "xyz",
  "picture": {
    "length": null,
    "mimetype": null,
    "filename": null
  }
}

You might consider it a detail, but this makes it more difficult for API users to check if there is content.

Adding some code to every entity that uses content is certainly possible, but to me it feels like additional effort that should not be needed to be able to use spring-content.

I think I would have to make it configurable

If taking the second approach (setAutoGrowNestedPaths in write paths; catching NullValueInNestedPathException and treating it as null in read paths) does not need configuration.

I can't immediately think of a situation where you would want an exception while trying to read/write content. That effectively makes two paths that need to be handled for the "no content present" case, one with the read returning null, and one with it throwing an (undeclared/undocumented) exception which is an internal implementation detail.

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.