I have a MySQL table where the dataType for the attribute workingDays is SET. something like this:
CREATE TABLE IF NOT EXISTS `course` (
`courseId` int(11) NOT NULL AUTO_INCREMENT,
`courseName` varchar(255) NOT NULL DEFAULT '0',
`courseDescription` varchar(255) DEFAULT NULL,
`courseDuration` int(11) DEFAULT NULL,
`courseBatchSize` int(11) NOT NULL DEFAULT '0',
`courseEnrolmentDate` date DEFAULT NULL,
`workingDays` set('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') DEFAULT NULL,
`courseFee` float DEFAULT NULL,
`isScholarshipAvailable` enum('Y','N') DEFAULT NULL,
`scholarshipCriteria` varchar(255) DEFAULT NULL,
`scholarshipExamDate` date DEFAULT NULL,
`successRate` tinyint(4) DEFAULT NULL,
`rating` tinyint(4) DEFAULT NULL,
`otherInfo` varchar(255) DEFAULT NULL,
`courseDiscount` float DEFAULT NULL,
`institute` int(11) DEFAULT NULL,
`exam` int(11) DEFAULT NULL,
PRIMARY KEY (`courseId`),
KEY `FK_INS` (`institute`),
KEY `FK_EX` (`exam`),
CONSTRAINT `FK_EX` FOREIGN KEY (`exam`) REFERENCES `exam` (`examId`),
CONSTRAINT `FK_INS` FOREIGN KEY (`institute`) REFERENCES `institute` (`instituteId`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 COMMENT='contains course info';
Now correspondingly I want to map with the pojo using jpa annotations. Presently I am doing it like this
@Column(name = "workingDays", nullable = false, unique = false)
@Type(type="org.hibernate.type.settype")
private Set<String> workingDays;
where the annotation @Column is from package javax.persistence. With @Type annotation which is from hibernate package I am getting an error
Caused by: java.lang.ClassNotFoundException: org.hibernate.type.settype
My pom.xml file has the following dependencies added
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.4.Final</version>
</dependency>
<!-- Hibernate library dependecy start -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<!-- Hibernate library dependecy end -->
I am not sure how to resolve this issue. any insight or other workaround for mapping to a set in MySQL database will be helpful.
EDIT: Also suggest if I can store the working days attribute in database without using SET. This working day attribute is for a particular Company class and I need to show what are the working days of that company to end user. Suggestion regarding the datatype will be really helpful too.
Thanks.