[EJB 3.0] - @Enumerated with non-ordinal enumeration
by Jeilong
Given this enumeration:
| public enum Gender {
|
| MALE ("M"), FEMALE ("F");
|
| private String codeInDatabase;
|
| private Gender(String codeInDatabase) {
| this.codeInDatabase = codeInDatabase;
| }
|
| public String getCodeInDatabase() {
| return codeInDatabase;
| }
| }
and this fragment from my POJO:
| @Enumerated(EnumType.STRING)
| @Column(name = "gender")
| public Gender getGender() {
| return gender;
| }
| public void setGender(Gender gender) {
| this.gender = gender;
| }
In the database the column "gender" contains the value M or F. When I query the pojo I get the following exception:
javax.ejb.EJBException: java.lang.IllegalArgumentException:
| Unknown name value for enum class com.company.enumeration.Gender: M
Is this a bug? Or is using non-ordinal enumerations not possible at all? I'm using 4.0.5.GA with the EJB3 profile.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993352#3993352
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993352
19 years, 4 months
[JBoss jBPM] - Saving TaksInstance, Task == NULL
by jstachera
I have a problem with saving task instance.
First I create the process instance and then I save it.
ProcessDefinition processDefinition = context.getGraphSession().findLatestProcessDefinition(pName);
| org.jbpm.graph.exe.ProcessInstance processInstance = new ProcessInstance(processDefinition);
| context.save(processInstance);
In next step I retrieve the process instance and create the start task. It takes place in different method with new context.
public static long createStartTaskInstance(int processInstanceId, JbpmDefSession session) throws Exception {
| JbpmContext context = session.getContext();
| try {
| ProcessInstance processInstance = context.getProcessInstance(processInstanceId);
| TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| context.save(taskInstance);
| return taskInstance.getId();
| }
| catch (Exception e) {
| log.error(e);
| }
| finally {
| context.close();
| }
| }
|
After creating the start task instance I checked the JBPM_TASKINSTANCE table for this task. I found that the task data does not have a reference to task (task_ column is empty) as well as it has empty name_ column, the rest is ok. Because of that it is not possible to get the Task definition from the task instance:
taskInstance.getTask()
returns null.
Where is the problem ?? Or maybe it can not be done in this way ??
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993350#3993350
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993350
19 years, 4 months