
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The ability to map a class to a database table has made database interaction in Java a lot easier. But map multiple classes to the same table and you'll end up with a classic case of the left hand not knowing what the right hand is doing. In the worse case scenario, it could lead to serious data corruption.
|
|
|
|
|
|
This rule raises an issue when multiple classes are mapped to the same table with Hibernate or JPA annotations.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
@Entity // implicitly mapped to "point" table
|
|
public class Point {
|
|
// ..
|
|
}
|
|
|
|
@Entity
|
|
@Table(name = "point") // Noncompliant
|
|
public class Spot {
|
|
// ...
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
"tableName" is also associated with "classname".
|
|
|
|
|
|
=== Highlighting
|
|
|
|
* primary: table name on second class
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 6 Oct 2015, 15:49:45 Ann Campbell wrote:
|
|
\[~nicolas.peru] I don't know if this would go in 'implementation details' but this rule should look at both classes and XML configuration files. In Hibernate, at least, you can map classes to tables in XML.
|
|
|
|
Also, since this is a cross-file check, I understand that we won't get to even the first half of it soon. :)
|
|
|
|
endif::env-github,rspecator-view[]
|