我得到了WebService,它在EJB上得到了日期,但结果是我错过了属于映射超类的attibute
@Entity
@Table(name = "REASON", schema = "XXX")
@NamedQueries({
})
@RequiredArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Reason extends SSEntity implements Serializable {
private static final long serialVersionUID = -7071943771305035766L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "REASON_ID")
private Long reasonId;
@NotNull
@Column(name = "INTERNAL_ID")
private Long internalId;
}映射超类
@MappedSuperclass
@RequiredArgsConstructor
@EqualsAndHashCode
@ToString
public abstract class SSEntity {
@NotNull
@Version
@Column(name = "UPDATE_TIMESTAMP", nullable = false)
@Setter
@Getter(onMethod=@__({@XmlJavaTypeAdapter(XmlTimestampAdapter.class)}))
private Timestamp updateTimestamp;
}我有列出原因的web服务方法,但是如果我使用EJB,就不会得到属性。
@WebService(name = "IIntegrationInboundRemoteWSSEI", targetNamespace = "http://XXX.WebServices")
public interface WebService {
@WebMethod
List<Reason> listReasonsAllEJB() throws Exception;
@WebMethod
List<Reason> listReasonsAll() throws Exception;
}web服务实现
@Stateless
@WebService(
serviceName = "RemoteWebService",
targetNamespace = "http://XXX.WebServices",
endpointInterface = "com.azs.ws.WebService",
portName = "RemoteWebServicePort"
)
public class WebServiceImpl implements WebService {
@EJB(beanName = "WsEJBImpl")
private WsEJB bean;
@Inject
private EntityManager entityManager;
@Override
public List<Reason> listReasonsAllEJB() throws Exception {
return bean.listRejectionReasonsAll();
}
@Override
public List<Reason> listReasonsAll() throws Exception {
return entityManager
.createNamedQuery("listReasons", Reason.class)
.setParameter("date", new Date())
.getResultList();
}
}EJB如下所示
@Remote
public interface WsEJB {
List<Reason> listReasonsAll() throws Exception;
}EJB实现
@Stateless
@Remote(WsEJB.class)
public class WsEJBImpl implements WsEJB {
@Inject
private EntityManager entityManager;
@Override
public List<Reason> listReasonsAll() throws Exception {
return entityManager
.createNamedQuery("listReasons", Reason.class)
.setParameter("date", new Date())
.getResultList();
}
}如您所见,listReasonsAllEJB()和listReasonsAll()方法也是这样
当我用SoapUI测试这些方法时,我得到


当使用EJB时,我失去了updateTimestamp属性,我缺少了什么?
发布于 2020-08-19 13:07:29
我的abstarct实体类必须序列化。
@MappedSuperclass
public abstract class SSEntity implements Serializable {
private static final long serialVersionUID = -5741595897057015891L;
@NotNull
@Version
@Column(name = "UPDATE_TIMESTAMP", nullable = false)
@Setter
@Getter(onMethod=@__({@XmlJavaTypeAdapter(XmlTimestampAdapter.class)}))
private Timestamp updateTimestamp;
}https://stackoverflow.com/questions/63468293
复制相似问题