Comments (17)
Okay, i narrowed it down a bit:
if we have a DataTable sending DataTableInput through POST-reqeust - DataTablesRepository outputs fields seemingly at random. But if it uses GET-request - JsonView annotation works all of the sudden.
Tested it on a second project - same behaviour.
Changed issue name.
from spring-data-jpa-datatables.
I'm having the same issue as you (earlier) do. I can not hide properties with @JSONVIEW not even with @JsonIgnore. I'm using v4.3
from spring-data-jpa-datatables.
Well... it's strange.... now it's working with both GET and POST. I've switch back and forth from one method to another and they started to work (using @JSONVIEW).
from spring-data-jpa-datatables.
@sebasira In my case it very consistently doesn't work.
from spring-data-jpa-datatables.
@iSosnitsky give a few days and I'll put my code here
from spring-data-jpa-datatables.
Now things get kinda odd.
It totally works if i use findAll(); with an empty DataTablesInput, like that:
@JsonView(DataTablesOutput.View.class)
@RequestMapping(value = "/users", method = RequestMethod.GET)
public DataTablesOutput<User> getUsers() {
return userRepository.findAll(new DataTablesInput());
}
But if i use DataTables provided input, it stops working:
@JsonView(DataTablesOutput.View.class)
@RequestMapping(value = "/users", method = RequestMethod.GET)
public DataTablesOutput<User> getUsers(@Valid DataTablesInput input) {
return userRepository.findAll(input);
}
Now i suspect DataTables itself.
i'm using DataTables 1.10.16
Update:
It only worked when i opened it in my browser and saw data from controller from there, which was XML.
But when i use Postman for example, it doesn't work.
If i explicitly declare that this method produces JSON, then it won't work in any way no matter how you bend it:
@JsonView(DataTablesOutput.View.class)
@RequestMapping(value = "/users", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
public DataTablesOutput<User> getUsers() {
return userRepository.findAll(new DataTablesInput());
}
Mapping to XML as i remember, was used in previous versions.
Therefore, i assume that json mapper is not even using this feature.
from spring-data-jpa-datatables.
Hi, I'm not able to reproduce with GET or POST requests: https://github.com/darrachequesne/spring-data-jpa-datatables-sample/tree/issue-79
In both cases, only id
, firstName
and lastName
are displayed.
from spring-data-jpa-datatables.
@darrachequesne Hi, thanks a lot for answering.
I downloaded the branch and now am trying to reproduce the issue.
The sample you provided works flawlessly, by the way.
from spring-data-jpa-datatables.
@darrachequesne Yeah, i reproduced it.
The issue was in WebConfig - i used Jackson-datatype-hibernate5 as a MessageConverter in my WebConfig.
Where can i show you modified sample project?
from spring-data-jpa-datatables.
Great! Could you please fork the repository, and push the branch with the failure on it?
from spring-data-jpa-datatables.
@darrachequesne https://github.com/iSosnitsky/spring-data-jpa-datatables-sample
from spring-data-jpa-datatables.
@iSosnitsky thanks for providing a way to reproduce! It seems you have to manually disable the DEFAULT_VIEW_INCLUSION
(it is disabled by default in Spring Boot, but was enabled in your case):
class HibernateAwareObjectMapper extends ObjectMapper {
public HibernateAwareObjectMapper() {
Hibernate5Module module = new Hibernate5Module();
module.disable(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION);
this.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
this.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+ this.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
this.registerModule(module);
}
}
from spring-data-jpa-datatables.
@darrachequesne Thanks, it works!
Mind if i put that in your project's Wiki?
from spring-data-jpa-datatables.
By the way, if you declare a lazy loaded field as a non-searchable, it won't be initialized:
{
data: 'office.city',
render: function (data) { return data ? data : '-'; },
searchable: false
}
from spring-data-jpa-datatables.
@iSosnitsky let's add that to the README, if you will.
Regarding the lazy-loaded field, it seems you are right! Would you mind opening a new issue for that?
from spring-data-jpa-datatables.
@darrachequesne Sure!
from spring-data-jpa-datatables.
Closed due to inactivity, please reopen if needed.
from spring-data-jpa-datatables.
Related Issues (20)
- Filter by "<column> NOT IN (<input array>)" HOT 2
- how to remove the text - filtered from X total entries HOT 1
- How to Work with UserDTO HOT 2
- Can we search date in data table? HOT 2
- Duplicates items after filtering HOT 2
- Log Exceptions or they are silently lost HOT 4
- Add support for Spring Boot 3.0.0 HOT 3
- Is it possible to use specification for view? HOT 2
- Is it possible to do a regular expression search using ~ in PostgreSQL? HOT 2
- AddOrder doesnt seem to work HOT 2
- Filtering data sometimes throws ORM exception (Hibernate 6.1) HOT 10
- No property 'findAll' found for type 'Class' HOT 4
- Performance issue (suggestions on database indexes) HOT 7
- [question] specifications and counting total records HOT 4
- Show ManyToMany data HOT 1
- enable datatable repositories without using DatatablesJpaRepositoryBean HOT 1
- Order can be null HOT 4
- Specify date format in global/column search when database column is date (Oracle) HOT 4
- Searching for a record with special (national) character "ř" doesn't work HOT 5
- Search Panes Error in Relationship Table HOT 3
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-data-jpa-datatables.