This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Software Teaming: A Mob Programming, Whole-Team Approach and have Woody Zuill and Kevin Meadows on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring (MVC): Saving into Database question

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'd like to ask about where did I go wrong in saving an entity into Database.

This is my Entity:



This is my ServiceImpl:



And this is the DAOImpl



And when I execute the DAOImpl, I get a... "String or binary data would be truncated." Where did I go wrong?

Thanks.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It means your Creator class's fields don't match the corresponding table's schema. What does the table's CREATE TABLE look like?
 
Kristian Wijaya
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Done by SQL Server:

CREATE TABLE [dbo].[M_CREATOR](
[CREATOR_ID] [varchar](5) NOT NULL,
[CREATOR_NAME] [varchar](50) NOT NULL,
CONSTRAINT [PK_M_CREATOR] PRIMARY KEY CLUSTERED
(
[CREATOR_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]



And this is my HBM XML:



Well, where did I go wrong in this?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're setting id field to a UUID string which can be as long as 36 characters and trying to write it into a 5-character wide id column.
Similar problem may occur if name is more than 50 chars.
 
reply
    Bookmark Topic Watch Topic
  • New Topic