Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
f966ece4
Commit
f966ece4
authored
9 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Testing constraint violation
parent
d2d67592
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
P/Sda1/Jpa/rdbms2catalog/solution/src/test/java/rdbms2catalog/TestSchemaConflict.java
+37
-0
37 additions, 0 deletions
...ution/src/test/java/rdbms2catalog/TestSchemaConflict.java
with
37 additions
and
0 deletions
P/Sda1/Jpa/rdbms2catalog/solution/src/test/java/rdbms2catalog/TestSchemaConflict.java
0 → 100644
+
37
−
0
View file @
f966ece4
package
rdbms2catalog
;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManagerFactory
;
import
javax.persistence.EntityTransaction
;
import
javax.persistence.Persistence
;
import
org.junit.Test
;
import
de.hdm_stuttgart.mi.sda1.sql2catalog.model.Description
;
import
de.hdm_stuttgart.mi.sda1.sql2catalog.model.Product
;
public
class
TestSchemaConflict
{
static
final
EntityManager
em
;
static
{
final
EntityManagerFactory
emFactory
=
Persistence
.
createEntityManagerFactory
(
"create-drop"
);
em
=
emFactory
.
createEntityManager
();
}
@Test
(
expected
=
javax
.
persistence
.
PersistenceException
.
class
)
public
void
insertData
()
{
{
final
EntityTransaction
transaction
=
em
.
getTransaction
();
transaction
.
begin
();
final
Product
monkeyPickedTea
=
new
Product
(
1
,
"Monkey Picked Tea"
,
null
);
new
Description
(
monkeyPickedTea
,
0
,
"Picked only by specially trained monkeys"
);
new
Description
(
monkeyPickedTea
,
0
,
"Rare wild Chinese tea"
);
// oops! Unique key violation
em
.
persist
(
monkeyPickedTea
);
transaction
.
commit
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment