This is a Java EE based example application that demonstrates lazy loading with Vaadin Grid components.
-
Configure a database connection in the application.properties file. By default, this example uses a MySQL database. You should include the driver dependency in the pom.xml file if you want to use a diferent database.
-
Create a person table:
CREATE TABLE person(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255)
);
- Insert some test rows in the person table. If you are using MySQL, you can run the following script:
DELIMITER //
CREATE PROCEDURE insert_people(IN amount INT)
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i <= amount DO
INSERT INTO person(first_name,last_name,email)
VALUES (CONCAT("First", i), CONCAT("Last", i), CONCAT("email", i, "@test.com"));
SET i = i + 1;
END WHILE;
END //
CALL insert_people(1000);
- Download, compile and run the app by running the following in a terminal:
git clone https://github.com/alejandro-du/lazy-loading-cdi-demo.git
cd lazy-loading-cdi-demo
mvn package wildfly-swarm:run
- Point your browser to http://localhost:8080.