63 200
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #11660 in Java | JSP | JSF for Mohana sundaram

Question #11660
how to retrieve data from database trigger to hibernate
Expert's answer
Database Query

CREATE OR REPLACE VIEW cameron AS
SELECT last_name
AS surname
FROM author
WHERE first_name = 'Cameron';

view
entity

@Entity
@NamedNativeQuery(name = "findUniqueCameronsInOrder",
query = "select * from cameron order by surname", resultClass =
Cameron.class)
public class Cameron implements java.io.Serializable
{

private static final long serialVersionUID =
8765016103450361311L;

private String surname;

@Id

@Column(name = "SURNAME", nullable = false, length = 50)
public String
getSurname() {
return surname;
}

public void
setSurname(final String surname) {
this.surname = surname;

}
}

Hibernate mapping file.

<mapping
class="examples.hibernate.spring.query.domain.Cameron" />

finally some
test !...

@Test
public void findTheCameronsInTheView() throws
Exception {
final List<Cameron> camerons =
findUniqueCameronsInOrder();
assertEquals(2,
camerons.size());
final Cameron judd = camerons.get(0);

final Cameron mcKenzie = camerons.get(1);
assertEquals("Judd",
judd.getSurname());
assertEquals("McKenzie",
mcKenzie.getSurname());
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions