What is the use of outputStreaming in SimpleClientHttpRequestFactory?

I am using OAuth2RestTemplate class of spring-security-oauth2-2.1.1.RELEASE for rest client services. Ideally, whenever an access token expires, the template should retry the failed request by fetching the new access token. But at times, when an access token is expired on post requests, the template is exiting with the following error:

org.springframework.web.client.ResourceAccessException: I/O error on POST request for “REQUEST-URL”: cannot retry due to server authentication, in streaming mode; nested exception is java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode

Upon searching, I got to know that this behavior is due to the outputStreaming variable of SimpleClientHttpRequestFactory and this is set to true by default. I tried to set this variable to false and everything works fine. But I am not aware of what happens if set outputStreaming variable to false. So I am trying to understand it’s purpose which helps me in deciding whether should I go ahead disabling the outputStreaming.

Thanks in advance!

Walking filetree throws error even tho the files should exist

I am trying to walk through a zip file and print out all files, but for some reason, it throws a NoSuchFileException as soon as it goes into any subfolder.

    FileSystem fs = FileSystems.newFileSystem(Paths.get(folder.getRoot().getAbsolutePath(), "test.zip"), null);

    Files.walkFileTree(fs.getPath("/"), new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
            System.out.println(file);
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFileFailed(Path file, IOException exc) {
            System.err.println(exc);
            return FileVisitResult.CONTINUE;
        }

    });

How come it even wants to go there if they don’t exist? Can anyone help me to solve this problem? The files should actually be there, at least they do when the test is executed by hand.

Getter/Setter vs class variables

I’ve been trying to grasp the ideas behind getters and setters for awhile now, but I can’t seem to find any clear answers.

So, what is the benefit of getter and setter functions as opposed to direct interaction with a class variable?

Appreciate any help!

Reverse otp authintication

Iam designing a app where I need phone number authintication so we are using otp authintication
Is there any other way to do user authintication
Like I was thinking instead of sending sms to the user how about genrated a otp and send it to the server from the client device using the device sms to authenticate the device

Android studio, Passing strings between activities, intents not working

I am currently working on a project with a friend, where we have a website hosting login details and such. when a user logs in it returns a token to the app, to use as verification for further api calls by the user. (ie. getting the profile). i need to pass this token across other activities (it is a string), and ive attempted to use intents, but every time i try it comes up with a null pointer exception, where the class i’m calling the intent from cant find the extra i’m sending. i’ve tried putting the code for creating the intent at the top of the onCreate method, however this returns 401 errors from the server as (i assume) the token has no value because it hasn’t been sent by the server using the JSONObject request yet.
here is the code for the main activity (all links removed)(i also didnt include all the imports and variable declarations as i figured they’re un-necessary)

    String Name,Pass,tokenString;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    button = (Button) findViewById(R.id.button);
    token = (TextView) findViewById(R.id.TV1);
    name = (EditText) findViewById(R.id.name);
    pass = (EditText) findViewById(R.id.pass);
    register = (Button) findViewById(R.id.button2);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

          Name = name.getText().toString();
            Pass = pass.getText().toString();



            if(Name.equals("") || Pass.equals("")){
                Toast.makeText(MainActivity.this, "Fields cannot be left empty!", Toast.LENGTH_SHORT).show();
            }

            StringRequest stringRequest = new StringRequest(Request.Method.POST, Url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {

                        JSONObject jsonObject =  new JSONObject(response);
                        setToken(jsonObject.getString("token"));

                        launchHomeActivity();

                    } catch (JSONException e) {
                        e.printStackTrace();

                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    if(error.networkResponse.statusCode==401) {
                        Toast.makeText(MainActivity.this, "Incorrect login details, please retry", Toast.LENGTH_SHORT).show();
                    }
                }
            }){
                protected Map<String,String> getParams() throws AuthFailureError{
                    Map<String,String> params = new HashMap<String, String>();
                    params.put("key", "1234");
                    params.put("email", Name);
                    params.put("password", Pass);
                    return params;
                }
            };
            MySingleton.getInstance(MainActivity.this).addToRequestQueue(stringRequest);
            name.setText("");
            pass.setText("");

        }

    });
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            launchRegisterActivity();
        }
    });

}
private void launchRegisterActivity() {

    Intent intent = new Intent(this, RegisterActivity.class);
    startActivity(intent);
}
private void launchHomeActivity() {


    Intent intent = new Intent(this, Home.class);
    startActivity(intent);
}

private void setToken(String token){
    tokenString = token;

}
public String getToken(){
    return tokenString;
}

public void createIntent(){
    Intent i = new Intent(this, Home.class);
    i.putExtra("Token", getToken());
    startActivity(i);
}

}

here is the code for the home activity (the relevant bits) :

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    token = (TextView) findViewById(R.id.TV1) ;
    title = (TextView) findViewById(R.id.welcome_Txt);



    Bundle extras = getIntent().getExtras();

   final String tokenString = extras.getString("Token");

Any help is greatly appreciated.
(p.s i’m very new at android studio, and learning as i go , thanks for the help)

resource server throws an exception only when access token is expired or invalid

I am using spring-security-oauth 2.0.10 and implementing a resource server that uses RemoteTokenServices to validate jdbc or JWT tokens.

when i am requesting with valid access token resource server gives me an valid response or resource.
but in case if i enter wrong access token or expired access token then application throws an below exception.
but ideally i want error like "access token is expired or aceess token is invalid". my reosurce server application different from my auth Server application ..

so please help me with your valuable response.
Thanks in advance

i want xml or json response from Authorization server to resource server when access token is expired or invalid.

org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,2]
Message: The markup in the document preceding the root element must be well-formed.; nested exception is java.io.IOException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,2]
Message: The markup in the document preceding the root element must be well-formed.
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:227)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:212)
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:884)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:868)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:622)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:498)
at org.springframework.security.oauth2.provider.token.RemoteTokenServices.postForMap(RemoteTokenServices.java:138)
at org.springframework.security.oauth2.provider.token.RemoteTokenServices.loadAuthentication(RemoteTokenServices.java:107)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager.authenticate(OAuth2AuthenticationManager.java:83)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,2]
Message: The markup in the document preceding the root element must be well-formed.
at com.fasterxml.jackson.dataformat.xml.util.StaxUtil.throwXmlAsIOException(StaxUtil.java:24)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:541)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:29)
at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:807)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2881)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:224)
... 44 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,2]
Message: The markup in the document preceding the root element must be well-formed.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:596)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:650)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:539)
... 48 more

Selenium Webdriver Timeout Exception: Expected condition failed: waiting for frame to be available

It’s a CRM application where I want to close two pop-ups which are displayed once user login. I have created a method for each pop-up where I am waiting for it’s frame to detect and clicking on ‘Close’ icon to close the pop-up. Below is the code:

package base;

import java.awt.AWTException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;

public class TC02_VerificationOfCustomerSearchPage extends 
TC01_LoginToRClaimsCRM{

@Test(priority = 0)
public void PendingEmailPopUPClose() throws InterruptedException, 
AWTException{
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("html/body/div[10]")));

//Close Pending Email pop-up.

driver.findElement(By.xpath(“html/body/div[1]/div[2]/div[2]/button”)).click();

driver.switchTo().frame("InlineDialog1_Iframe");
}

@Test(priority = 1)
public void MSCRMPopUPClose() throws InterruptedException, AWTException {
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("html/body/div[10]")));

//Close MSCRM pop-up.
driver.findElement(By.xpath(".//*[@id='buttonClose']/div/img")).click();

driver.switchTo().frame("InlineDialog_Iframe");
}

@Test(priority = 2)
public void HomePageVerification() throws InterruptedException, AWTException 
{
driver.switchTo().defaultContent();

driver.findElement(By.cssSelector(".homeButtonImage")).click();

System.out.println("Home page is displayed.");

Thread.sleep(100);

System.out.println("Verification of Customer Search page UI.");

driver.switchTo().frame("contentIFrame0");

//Verification of Customer Search page UI.

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

//Main Policy Holder tab.
if(driver.findElement(By.tagName("html")).getText().contains("Main Policy Holder")){
    System.out.println("Main Policy Holder tab is displayed.");
    }else{
    System.out.println("Main Policy Holder tab is not displayed.");
    }

//SEARCH CRITERIA label.
if(driver.findElement(By.tagName("html")).getText().contains("SEARCH 
CRITERIA")){
    System.out.println("SEARCH CRITERIA label is displayed.");
    }else{
    System.out.println("SEARCH CRITERIA label is not displayed.");
    }

Thread.sleep(1000);

//MPH Name text field.
if(driver.findElement(By.cssSelector("#txtCustomerName")) != null){
    System.out.println("MPH Name text field is displayed.");
    }else{
    System.out.println("MPH Name text field is not displayed.");
    }

Thread.sleep(2000);

//MPH Number text field.
if(driver.findElement(By.cssSelector("#txtCustomerNumber")) != null){
    System.out.println("MPH Number text field is displayed.");
    }else{
    System.out.println("MPH Number text field is not displayed.");
    }

Thread.sleep(1000);

//MPH Policy Number.
if(driver.findElement(By.cssSelector("#txtPolicyNo")) != null){
    System.out.println("MPH Policy Number text field is displayed.");
    }else{
    System.out.println("MPH Policy Number text field is not displayed.");
    }

Thread.sleep(1000);

//SEARCH button.
if(driver.findElement(By.tagName("html")).getText().contains("SEARCH")) {
    System.out.println("SEARCH button displayed.");
    }else{
    System.out.println("SEARCH button is not displayed.");
    }

Thread.sleep(1000);

//RESET button.
if(driver.findElement(By.tagName("html")).getText().contains("RESET")) {
    System.out.println("RESET button displayed.");
    }else{
    System.out.println("RESET button is not displayed.");
    }

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println("Verification Successfull - Customer Search page UI."); 
}
}

Should you separate matrix data and math?

I am trying to make some simple classes to do the math necessary for OpenGL transformations. However, now that I am about halfway and while looking through different examples I find that most libraries keep the math separate of the matrix class itself (most of the times in math class with static methods). What exactly is the reason for this?

Is it when you’re creating multiple of the matrix objects that the functions are also created multiple times, which impacts performance or something else entirely?

Example:
I find it much easier to add the math functions to the matrix class so I dont need to pass the matrix itself to the functions: e.g.

class Matrix4f {

    //constructor...

    public void rotate(double theta) {
        setValue(0, 0, (float) Math.cos(theta));
        setValue(1, 0, (float) Math.sin(theta));
        setValue(0, 1, (float) Math.sin(theta));
        setValue(1, 1, (float) Math.cos(theta));
    }

    //getters and setters...
}

instead of

public class LinearAlgebraMath {
    public static Matrix4f rotate(Matrix4f target, double theta) {
        target.setValue(0, 0, (float) Math.cos(theta));
        target.setValue(1, 0, (float) Math.sin(theta));
        target.setValue(0, 1, (float) Math.sin(theta));
        target.setValue(1, 1, (float) Math.cos(theta));
        return target;    
    }
}

public class Matrix4f {

    //constructor...

    //getters and setters...
}

So, in the end I like adding the math functions to the matrix class because it’s easier for me (especially when dealing with dealing with math operations that use multiple data structures) but I don’t want to have my preferences lower performance, so my question is: Does example below outperform the example above and if yes, why?

ScrollView inside Coordinatorlayout

What i have:

<CoordinatorLayout>
    <AppBar>
    <NestedScrollView>
        <LinearLayout>
        </LinearLayout>
    </NestedScrollView>
    <FAB>
</CoordinatorLayout>

AppBarLayout, CoordinatorLayout etc are not special.
Inside my LinearLayout i have a TextView with some text info and an EditText for text typing.

What i wanna reach: i need my EditText to be at bottom of my NestedScrollView
So if text inside TextView is big – scrollview should scroll, if text is not big enough, ScrollView should not be scrollable and EditText should be at bottom. Anyway – EditText should be always at bottom of my ScrollView and scrollable if needed.

But now i have – even if. text is small, my ScrollView is scrollable, and EditText is not at bottom.

<CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:stateListAnimator="@animator/appbar_elevation"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="@color/colorWhite">

            <ImageView
                android:id="@+id/ivHeader"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/temp_big"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </AppBarLayout>

    <NestedScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorGold"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/myTemp"
                android:textSize="18sp" />


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/big_margin"
                android:layout_marginTop="@dimen/big_margin"
                android:fontFamily="sans-serif"
                android:text="2 comments"
                android:textColor="@color/colorBlack"
                android:textSize="17sp" />

            <View
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:layout_marginLeft="@dimen/big_margin"
                android:layout_marginTop="@dimen/small_margin"
                android:alpha="0.5"
                android:background="@color/colorSecondaryText" />


            <Space
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp">

                <View
                    android:layout_width="match_parent"
                    android:layout_height="0.5dp"
                    android:alpha="0.5"
                    android:background="@color/colorSecondaryText" />

                <android.support.v7.widget.AppCompatEditText
                    android:id="@+id/etComment"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/big_margin"
                    android:layout_marginTop="@dimen/big_margin"
                    android:background="@android:color/transparent"
                    android:hint="write a comment"
                    android:textColor="@color/colorBlack"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/imageView"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="4dp"
                    android:layout_marginRight="4dp"
                    android:layout_marginTop="4dp"
                    android:src="@drawable/ic_send"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </android.support.constraint.ConstraintLayout>
        </LinearLayout>
    </NestedScrollView>

    <ImageView
        android:id="@+id/btnTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginBottom="32dp"
        android:layout_marginRight="@dimen/big_margin"
        android:src="@drawable/ic_back_top"
        android:translationY="500dp" />
</CoordinatorLayout>

If i use war_content of LinearLayout or NestedScrollView – scrolling behavior with small text is good, but EditText is not at bottom.

#EDIT1 Also if LinearLayout content is small – after start AppBar collapsing immediately.

How to force hibernate not to load subentities

I have A and B entities where A can have more Bs

@Entity
@Table(name = "A")
public class A {

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "b_id", nullable = false, insertable = true, updatable = false)
private Set<B> bs;

}

what I need is to say jpa somehow not to load set of Bs in special situations.

I tried it other way around, I defined fetch = FetchType.Lazy and then I say hibernate when i want to load B. Problem is however, that when i do a.getBs(), hibernate loads the bs even when i dont want this behaviour ( I wanted only check if B is loaded or not). It means I need to force hibernate with jpa not to load subentities later (a.getBs()) with lazy load mode OR to force not to load entities with eager load mode.

In jpa there is method Root.fetch(). I would need Root.unfetch()