AngularJS Relationships with Hibernate

Working with two classes that have a one-to-one relation, I have successfully retrieved their data and displayed it in HTML using REST service and AngularJS. However, when attempting to display the airport ID on the asset page using {{asset.airport.id}}, nothing is showing up. How can I properly handle Hibernate relations in AngularJS for one-to-one, one-to-many, and many-to-many relationships?

Here is the code:

<tr ng-repeat="asset in assets">
    <td>{{asset.id}}</td>
    <td>{{asset.assetName}}</td>
    <td>{{asset.airport.id}}</td>
<tr>

Asset class:

public class Asset implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@Column(name = "name")
private String assetName;

@JsonIgnore
@OneToOne(mappedBy = "asset", fetch=FetchType.EAGER)
private Airport airport;

Airport Class:

 public class Airport implements Serializable {
 @Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@Column(name = "iata_code")
private String iatacode;

@JsonIgnore
@OneToOne(fetch=FetchType.EAGER)
private Asset asset;

Answer №1

If you're facing issues, consider using the following annotations:

@JsonBackReference
@JsonManagedReference

To better understand how these annotations work, take a look at the resources below:

Hope this helps!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Concealing Enclosures in Jade - AngularJS Syntax

Struggling with writing this in Jade, specifically the .get() function is giving me trouble. <li ng-repeat="breadcrumb in breadcrumbs.get() track by breadcrumb.path" ng-class="{ active: $last }"></li> Seen from: https://github.com/ianwalter/n ...

Protecting your application with Spring security and integrating Ajax functionalities

My spring security setup currently redirects to the login page when a user is not authenticated: <form-login login-page="/login/" authentication-failure-handler-ref="customAuthenticationFailureHandler" authentication-success-handler-ref="custom ...

Using ChromeDriver or FirefoxDriver in Selenium without the need for its graphical user interface (headless mode)

JAVA (selenium code snippet): manageDriver(); WebDriver driver = new ChromeDriver(); driver.get(url); driver.manage().timeouts().implicitlyWait(3+r, TimeUnit.SECONDS); This sample code creates a ChromeDriver window that can be bothersome ...

Ways to obtain the final day of the previous month

Attempting to utilize automated bots here, I am in need of retrieving the last day of the previous month. The bot performs accurately on the current month during the first run; however, when transitioning to the next month, the date retrieved from this cod ...

Webix UI - Struggling to create dynamically responsive components during screen resizing

Can anyone guide me on how to make my Webix UI control responsive in the free version available at ? It seems to be acting unpredictably due to the AngularJS integration code I'm using. I have attempted various solutions like media queries, redraw, a ...

Encountering an issue with GSON while attempting to convert an array of objects with

I'm trying to make a HTTP request using Retrofit that should return an array of objects, but unfortunately I'm encountering the following errors: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was ...

The foundation of the Selenium framework seems to be malfunctioning

As a beginner in Selenium, I attempted to create a basic framework that isn't functioning correctly. I utilized TESTNG and DataProvider annotation. If anyone could provide assistance or recommend an alternative framework/code, it would be greatly app ...

Is there a way to display a loader when an item is selected from a dropdown menu? For example, while data is being fetched from the backend, can we

This is the HTML form division I have created: <div class="col-lg-2 "> <select name="limitCount" id="limitCount" ng-model="limitCount" class="form-control col-md-2 panel-refresh" ...

Dealing with Spring MVC: Error 415 when converting JSON to Pojo

While working on my jQuery code, I am creating JSON data and sending it to a controller using ajax. Here is the code snippet: var jsonResponse = []; $(columns).each(function() { if(!isEmpty($(this))) { var lang = $(this).find(".language"). ...

Exploring HTML5 video playback in AngularJS

When I use this code: <video id="video" class="video-js vjs-default-skin" controls width="640" height="264"> <source src="http://localhost:3000/files/public/photos/Let-her-go.mp4" type='video/mp4' /> <p class="v ...

The AngularJS application runs faster after traversing through multiple views and remains responsive without freezing when clicked to view

I'm having trouble understanding why my AngularJS app behaves differently after visiting one or multiple pages. When I first deploy my website, clear the cache, and navigate to a page, I notice that it reacts slowly. Clicking on links to open new pag ...

Unleashing the Potential: Integrating a Scanner Device with

Currently, I'm facing the challenge of integrating a Scanner device with my Angular application. On one of the pages dedicated to scanning, users are able to view an alert indicating the connection status of the Scanner as well as any scanned document ...

"Creating dynamic web apps with the powerful duo of Meteor and Zurb

Just starting out with programming and currently working on a new web application using Meteor and AngularJS. I would like to incorporate the elements/css from 'Zurb Foundation For Apps' into my project... I am familiar with including Bootstrap ...

Removing information from a MongoDB database with the help of AngularJS and Node.js

Having trouble deleting data in MongoDB using AngularJS and Node.js, as I keep encountering the error "Cannot DELETE /api/manage-product" in the console. .html file <tbody> <tr ng-repeat="product in vm.result"> ...

Java's UnreachableBrowserException in Selenium

System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.navigate().to("https://link"); driver.findElement(By.cssSelector("#username")).sendKeys("id"); driver.find ...

Can you explain the meaning of arguments[0] and arguments[1] in relation to the executeScript method within the JavascriptExecutor interface in Selenium WebDriver?

When utilizing the executeScript() method from the JavascriptExecutor interface in Selenium WebDriver, what do arguments[0] and arguments[1] signify? Additionally, what is the function of arguments[0] in the following code snippet. javaScriptExecutor.ex ...

Troubleshooting: Issue with AngularJS $location.path functionality

I have some queries related to the usage of $location.path(/helpmeunderstand). I have a method called login() and when the login credentials are successful, I want to redirect to $location.path(/login/:username). However, instead of displaying the username ...

Is there a resource that provides a practical example of Java combined with Selenium and PageObject implementation?

While I have some basic experience with Selenium and Java, I am now seeking to delve deeper into the Page Object Pattern. However, I am having difficulty grasping how to effectively implement it in a real project. Despite my efforts to find straightforward ...

Utilizing AngularJS to compare information within multiple JSON arrays and assigning a chosen option

$scope.opts = { unit: [ { id: 1, val: "px", name: "px"}, { id: 2, val: "%", name: "%"} ] } The options list array above is defined and the default option is set. $scope.user.unit = $scope.opts.unit[0]; The ...

Exploring the potential of Angular $q integration with the dynamic testing duo of Jasmine 2

Looking to perform a test on a promise-based service that functions like this: load : function(){ var deferred = $q.defer(); //Perform miscellaneous asynchronous tasks deferred.resolve(); return deferred.promise; } W ...