SQL Server CLOB data to String Java + Angular

Multi tool use
I am using SQL Server database and one to of the table has CLOB
data. I am using Spring Boot + Hibernate framework. When I fetch the data using repository I have getting some encoded string (its stream, i need to convert CLOB
to String
), when i use database as SQL server. If I use database as H2 memory database and MySQL then I am getting proper string. So there is something extra I need to configure with SQL server, I am not sure what setting with Hibernate CLOB
field as String
.
@Entity
@Table(name = "pivotwidgets")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Pivotwidgets implements Serializable {
.....
@Lob
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
.....
}
I have below JPA repository :-
public interface PivotwidgetsRepository extends JpaRepository<Pivotwidgets, UUID>, JpaSpecificationExecutor<Pivotwidgets> {
}
@Service
@Transactional
public class PivotwidgetsServiceImpl implements PivotwidgetsService {
@Override
@Transactional(readOnly = true)
public Pivotwidgets findOne(UUID id) {
log.debug("Request to get Pivotwidgets : {}", id);
Optional<Pivotwidgets> pivotwidgets = pivotwidgetsRepository.findById(id);
return pivotwidgets.get();
}
}
When I call above service with Controller, I can see CLOB
data as stream like :-
Request URL:
http://localhost:9000/api/pivotwidgets/6f6ff3e9-0db2-4525-9e3a-5713d5a0b198
response :-
{
"id" : "6f6ff3e9-0db2-4525-9e3a-5713d5a0b198",
"properties" : "獡慤摳"
}
How can I handle properties filed conversion?
java


add a comment |
I am using SQL Server database and one to of the table has CLOB
data. I am using Spring Boot + Hibernate framework. When I fetch the data using repository I have getting some encoded string (its stream, i need to convert CLOB
to String
), when i use database as SQL server. If I use database as H2 memory database and MySQL then I am getting proper string. So there is something extra I need to configure with SQL server, I am not sure what setting with Hibernate CLOB
field as String
.
@Entity
@Table(name = "pivotwidgets")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Pivotwidgets implements Serializable {
.....
@Lob
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
.....
}
I have below JPA repository :-
public interface PivotwidgetsRepository extends JpaRepository<Pivotwidgets, UUID>, JpaSpecificationExecutor<Pivotwidgets> {
}
@Service
@Transactional
public class PivotwidgetsServiceImpl implements PivotwidgetsService {
@Override
@Transactional(readOnly = true)
public Pivotwidgets findOne(UUID id) {
log.debug("Request to get Pivotwidgets : {}", id);
Optional<Pivotwidgets> pivotwidgets = pivotwidgetsRepository.findById(id);
return pivotwidgets.get();
}
}
When I call above service with Controller, I can see CLOB
data as stream like :-
Request URL:
http://localhost:9000/api/pivotwidgets/6f6ff3e9-0db2-4525-9e3a-5713d5a0b198
response :-
{
"id" : "6f6ff3e9-0db2-4525-9e3a-5713d5a0b198",
"properties" : "獡慤摳"
}
How can I handle properties filed conversion?
java


add a comment |
I am using SQL Server database and one to of the table has CLOB
data. I am using Spring Boot + Hibernate framework. When I fetch the data using repository I have getting some encoded string (its stream, i need to convert CLOB
to String
), when i use database as SQL server. If I use database as H2 memory database and MySQL then I am getting proper string. So there is something extra I need to configure with SQL server, I am not sure what setting with Hibernate CLOB
field as String
.
@Entity
@Table(name = "pivotwidgets")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Pivotwidgets implements Serializable {
.....
@Lob
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
.....
}
I have below JPA repository :-
public interface PivotwidgetsRepository extends JpaRepository<Pivotwidgets, UUID>, JpaSpecificationExecutor<Pivotwidgets> {
}
@Service
@Transactional
public class PivotwidgetsServiceImpl implements PivotwidgetsService {
@Override
@Transactional(readOnly = true)
public Pivotwidgets findOne(UUID id) {
log.debug("Request to get Pivotwidgets : {}", id);
Optional<Pivotwidgets> pivotwidgets = pivotwidgetsRepository.findById(id);
return pivotwidgets.get();
}
}
When I call above service with Controller, I can see CLOB
data as stream like :-
Request URL:
http://localhost:9000/api/pivotwidgets/6f6ff3e9-0db2-4525-9e3a-5713d5a0b198
response :-
{
"id" : "6f6ff3e9-0db2-4525-9e3a-5713d5a0b198",
"properties" : "獡慤摳"
}
How can I handle properties filed conversion?
java


I am using SQL Server database and one to of the table has CLOB
data. I am using Spring Boot + Hibernate framework. When I fetch the data using repository I have getting some encoded string (its stream, i need to convert CLOB
to String
), when i use database as SQL server. If I use database as H2 memory database and MySQL then I am getting proper string. So there is something extra I need to configure with SQL server, I am not sure what setting with Hibernate CLOB
field as String
.
@Entity
@Table(name = "pivotwidgets")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Pivotwidgets implements Serializable {
.....
@Lob
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
.....
}
I have below JPA repository :-
public interface PivotwidgetsRepository extends JpaRepository<Pivotwidgets, UUID>, JpaSpecificationExecutor<Pivotwidgets> {
}
@Service
@Transactional
public class PivotwidgetsServiceImpl implements PivotwidgetsService {
@Override
@Transactional(readOnly = true)
public Pivotwidgets findOne(UUID id) {
log.debug("Request to get Pivotwidgets : {}", id);
Optional<Pivotwidgets> pivotwidgets = pivotwidgetsRepository.findById(id);
return pivotwidgets.get();
}
}
When I call above service with Controller, I can see CLOB
data as stream like :-
Request URL:
http://localhost:9000/api/pivotwidgets/6f6ff3e9-0db2-4525-9e3a-5713d5a0b198
response :-
{
"id" : "6f6ff3e9-0db2-4525-9e3a-5713d5a0b198",
"properties" : "獡慤摳"
}
How can I handle properties filed conversion?
java


java


edited Jan 2 at 4:50


Gayan Mettananda
1,106713
1,106713
asked Jan 2 at 4:21
Varun JainVarun Jain
851315
851315
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can try as follows
@Lob
@Type(type="text")
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001156%2fsql-server-clob-data-to-string-java-angular%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try as follows
@Lob
@Type(type="text")
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
add a comment |
You can try as follows
@Lob
@Type(type="text")
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
add a comment |
You can try as follows
@Lob
@Type(type="text")
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
You can try as follows
@Lob
@Type(type="text")
@Column(name = "properties", columnDefinition="CLOB")
private String properties;
answered Jan 2 at 6:56
shawonshawon
11614
11614
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
add a comment |
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
perfect, its working as expected.
– Varun Jain
Jan 2 at 13:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001156%2fsql-server-clob-data-to-string-java-angular%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
vi,gcB,8Q,rwA 0,2I2l41fd,ajog7r7CMdRPtGnx5T,BzHqD7z3Cicy7fB2N,v6b0OjgGK0 LV2qSOQnnQ Qq3b