Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
fa4003fc
Commit
fa4003fc
authored
14 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
minor: fixed error message in sample batch import when code is not unique
SVN: 16541
parent
f4b76692
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAO.java
+29
-20
29 additions, 20 deletions
.../cisd/openbis/generic/server/dataaccess/db/SampleDAO.java
with
29 additions
and
20 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAO.java
+
29
−
20
View file @
fa4003fc
...
@@ -178,23 +178,8 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
...
@@ -178,23 +178,8 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
internalCreateSample
(
sample
,
hibernateTemplate
,
internalCreateSample
(
sample
,
hibernateTemplate
,
new
ClassValidator
<
SamplePE
>(
SamplePE
.
class
),
true
);
new
ClassValidator
<
SamplePE
>(
SamplePE
.
class
),
true
);
try
{
flushWithSqlExceptionHandling
(
hibernateTemplate
);
hibernateTemplate
.
flush
();
}
catch
(
UncategorizedSQLException
e
)
{
// need to deal with exception thrown by trigger checking code uniqueness
final
SQLException
sqlExceptionOrNull
=
ExceptionUtils
.
tryGetThrowableOfClass
(
e
,
SQLException
.
class
);
if
(
sqlExceptionOrNull
!=
null
&&
sqlExceptionOrNull
.
getNextException
()
!=
null
)
{
throw
new
DataIntegrityViolationException
(
sqlExceptionOrNull
.
getNextException
()
.
getMessage
());
}
else
{
throw
e
;
}
}
}
}
public
List
<
SamplePE
>
listSamplesWithPropertiesByExperiment
(
final
ExperimentPE
experiment
)
public
List
<
SamplePE
>
listSamplesWithPropertiesByExperiment
(
final
ExperimentPE
experiment
)
...
@@ -474,7 +459,9 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
...
@@ -474,7 +459,9 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
{
{
operationLog
.
info
(
String
.
format
(
"ADD: %d samples."
,
samples
.
size
()));
operationLog
.
info
(
String
.
format
(
"ADD: %d samples."
,
samples
.
size
()));
}
}
hibernateTemplate
.
flush
();
// TODO 2010-06-16, Piotr Buczek: is memory usage increasing without clear of session?
flushWithSqlExceptionHandling
(
getHibernateTemplate
());
}
}
public
final
void
updateSample
(
final
SamplePE
sample
)
throws
DataAccessException
public
final
void
updateSample
(
final
SamplePE
sample
)
throws
DataAccessException
...
@@ -482,9 +469,9 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
...
@@ -482,9 +469,9 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
assert
sample
!=
null
:
"Unspecified sample"
;
assert
sample
!=
null
:
"Unspecified sample"
;
validatePE
(
sample
);
validatePE
(
sample
);
final
HibernateTemplate
hibernateTemplate
=
getHibernateTemplate
();
getHibernateTemplate
().
flush
();
flushWithSqlExceptionHandling
(
getHibernateTemplate
());
hibernateTemplate
.
flush
();
if
(
operationLog
.
isInfoEnabled
())
if
(
operationLog
.
isInfoEnabled
())
{
{
operationLog
.
info
(
"UPDATE: sample '"
+
sample
+
"'."
);
operationLog
.
info
(
"UPDATE: sample '"
+
sample
+
"'."
);
...
@@ -507,4 +494,26 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
...
@@ -507,4 +494,26 @@ public class SampleDAO extends AbstractGenericEntityDAO<SamplePE> implements ISa
return
list
;
return
list
;
}
}
private
static
void
flushWithSqlExceptionHandling
(
HibernateTemplate
hibernateTemplate
)
throws
DataAccessException
{
try
{
hibernateTemplate
.
flush
();
}
catch
(
UncategorizedSQLException
e
)
{
// need to deal with exception thrown by trigger checking code uniqueness
final
SQLException
sqlExceptionOrNull
=
ExceptionUtils
.
tryGetThrowableOfClass
(
e
,
SQLException
.
class
);
if
(
sqlExceptionOrNull
!=
null
&&
sqlExceptionOrNull
.
getNextException
()
!=
null
)
{
throw
new
DataIntegrityViolationException
(
sqlExceptionOrNull
.
getNextException
()
.
getMessage
());
}
else
{
throw
e
;
}
}
}
}
}
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