ListArrayType should match the initial type when populating the List with the array from the DB
See original GitHub issueWhen having a entity like:
@Entity
@TypeDefs({
@TypeDef(name = "list-array", typeClass = ListArrayType.class)
})
public class Circuit {
@Column(name = "previous_names")
@Type(type = "list-array")
private List<String> previousNames = new ArrayList<>();
..
Could the ListArrayType
add the names to the initiated list instead of replacing the list?
I’m wondering as when the array is null in the database the previousNames
list will be null in the fetched entity. I’m having 2 feelings here as it makes sense if it’s null in the database.
But I expected differently.
Similar as
@OneToMany(mappedBy = "project")
private List<Task> tasks = new ArrayList<>();
will also give an empty list, even if no tasks would be found in the databse.
Maybe
@Type(type = "list-array")
private List<String> previousNames = new ArrayList<>();
could return an empty list.
and
@Type(type = "list-array")
private List<String> previousNames;
could return null.
What do you think?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
java - The type of the expression must be an array type but it ...
An ArrayList is not an array . The syntax to get the element at index i is different: list.get(i) vs arr[i] . Read...
Read more >Arrays - Rosetta Code
Creating an array is as simple as declaring its base address. Note that all bounds checking must be done by the programmer and...
Read more >Documentation: 15: 8.15. Arrays - PostgreSQL
To illustrate the use of array types, we create this table: ... Multidimensional arrays must have matching extents for each dimension.
Read more >How To Manage State in React with Redux - DigitalOcean
That means your actions and reducers will be defined by the type of feature they will impact. Create a directory called store :...
Read more >How to map a PostgreSQL ARRAY to a Java List with JPA and ...
Even if Hibernate ORM does not support these column type mappings by default, you can still use all these database column types as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’re welcome. I think the current behavior follows the “principle_of_least_astonishment”, so it’s better to leave it as-is.
OK, I wasn’t aware of the
@Basic
property rules, but it makes sense. I indeed added a getter like that already. Thx again.