Spring-data-jpa automatically limits query results according to conditions

this is a question post with nothing to do, the problem encountered by the beginner of programming, there is no solution, I do not know which seniors have ideas, but also hope to give me some advice.
is like this

    The
  1. project uses spring-data-jpa as the persistence layer framework to read the database in an object-oriented way.
  2. can now handle one-to-one, one-to-many, many-to-many relationships and output their most json data.
  3. when I query an object with a complex structure, I will get all the properties related to it, such as Class A has two fields name,age,password, then Class B inherits Class A, so when I query Class B, I will query all the name,age,password. Now I want to only query name,age without showing how to implement password? What I hope is not to block out all password, but to block him in this query. Take a chestnut. If another class C inherits An at the same time, it will query all name,age,password when querying C. ,
  4. is the same as the expression of 3, but now the attribute has become an object. Class A has an object A1 Magi B2c3, because Class B, Class C inherits Class A, so when I query Class B, I will query all the attributes of B2C3, but I want to query C3 when I query Class B, and do not show B when querying Class C. how can I do this?

I hope that the seniors with ideas will stop and point out the way for my little brother. Thank you here!

Mar.02,2021

suppose there is object A, in which there are attributes name,age,password, object query can only find out all, can not find the specified object, and look up a field and all fields performance almost no difference, I think you this is a false requirement.

suppose there is an object A br B.
A has an attribute name,age,b, in it and An and B are configured with an one-to-many relationship. By default, object An is queried and object B is not immediately detected. The reason is that in the case of one-to-many, FetchType fetch () default LAZY; , if you want to find all the sets of B, just set @ OneToMany (fetch = FetchType.EAGER) .
if there is a many-to-one relationship between An and B, object A will be queried by default, and object B will also be queried. Just set @ ManyToOne (fetch = FetchType.LAZY) , and object B will be queried immediately. You can set up the log and take a look at the sql statement printed in the console to test it.

Menu