Questions tagged as 'jpa'

1
answer

java.lang.ClassNotFoundException: Could not load requested class: com.mysql.jdbc.Driver

I have a Dynamic Web Project in Eclipse and I have been constantly receiving this error: java.lang.ClassNotFoundException: could not load requested class: com.mysql.jdbc.Driver. My persistence.xml file: <persistence-unit name="casos">...
asked by 24.01.2018 / 21:53
1
answer

Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements

Good Night. I have the following error in Hibernate:    org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: bestroute.modelo.Peca.grupoPeca I can not display on...
asked by 01.10.2017 / 03:17
1
answer

Error requesting GET, JavaScript, Angular, Spring, Java

I'm having an error opening the screen with the search results in the database. The error is in the image below. Debugging, data is coming from the database. In the other image, the Server Log appears MyNeighborhoods@Entity@Table(nam...
asked by 25.09.2017 / 15:10
1
answer

Equivalent to sql function LEFT () in JPA

What is the equivalent function of LEFT () in JPA? I need to get only the first 6 characters of a field. The equivalent select in sql would be: select left(campo,6), count(*) qtd from tabela group by left(campo,6)     
asked by 11.08.2017 / 22:25
1
answer

Tables not being generated - Hibernate

I have 2 tables in my software that are not being generated correctly. SQL is generated, but when verifying in MySQL, not the meetings. If I change the tag to: <property name="hibernate.hbm2ddl.auto" value="validate"/> or <...
asked by 05.09.2017 / 14:16
1
answer

Show sql generated by JPA / Hibernate

Is there any way to show the SQL generated by JPA / Hibernate without being enabled by the <property name="hibernate.show_sql" value="true"/> property? The difficulty is that I need to monitor only one query, and if I turn on...
asked by 20.07.2017 / 18:38
1
answer

Error saving related entities - Unsave transient instance

A subsidiary has a product - relationship @OneToOne - and a product has several histories. Implemented registration method: public class CadastroProdutoService implements Serializable { private static final long serialVersionUID = 1...
asked by 07.06.2017 / 14:58
1
answer

How to map entities with composite keys in JPA?

I have a system where all tables in the database have a column empresa , which is part of PRIMARY KEY . In the client table, I have a column id (autoincrement), which together with empresa form a composite key, mappe...
asked by 09.04.2017 / 23:57
2
answers

Error with popular array with Double

I need to put in a array of double the data of the quantity field that comes from the database. When doing this with the following code: static List<Historico> listaComCincoUltimosMeses = new ArrayList<Historico> ();...
asked by 11.05.2017 / 21:00
1
answer

Save only if it is not null

How do I map with Hibernate @OneToOne and save only if the information has data in the related table? Example: public class ObservacaoPessoa { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) public Integer id;...
asked by 16.02.2017 / 13:30