如何使用Spring-WS发布具有动态soap:address位置的WSDL定义(How to publish a WSDL definition with dynamic soap:address location using Spring-WS)
我想根据持有它们的环境更改WSData的
<soap:address location="..."/>
。 例如:开发:
<soap:address location="https://development.xxx.yyy.zz/abc/ws/"/>
测试:
<soap:address location="https://testing.xxx.yyy.zz/abc/ws/"/>
制作:
<soap:address location="https://production.xxx.yyy.zz/abc/ws/"/>
I want to change the
<soap:address location="..."/>
of WSDLs depending on the environment that holds them. For example:Development:
<soap:address location="https://development.xxx.yyy.zz/abc/ws/"/>
Testing:
<soap:address location="https://testing.xxx.yyy.zz/abc/ws/"/>
Production:
<soap:address location="https://production.xxx.yyy.zz/abc/ws/"/>
原文:https://stackoverflow.com/questions/40939937
最满意答案
Yogesh Sakurikar很接近,但双向
@JoinColumn
有点偏。 您将在下面看到如何双向或单向连接@Entity(name = "GARDEN") public class Garden { @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(name = "NAME", nullable = false) private String name; // "Oak Grove" // use this if you don't want a bi-directional relationship // @OneToMany // @JoinColumn(name = "ID", referencedColumnName="GARDEN_ID") // private List<Plant> plants; // use this if you want it bi-directional @OneToMany(fetch = FetchType.LAZY, mappedBy = "garden") private Set<Plant> plants; } @Entity(name = "PLANT") public class Plant { @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(name = "NAME", nullable = false) private String name; // "Cherry Tomato" // use this if you don't want a bi-directional relationship // @Column(name="GARDEN_ID") // private long gardenId; // use this if you want a bi-directional relationship @ManyToOne @JoinColumn(name = "GARDEN_ID", referencedColumnName="ID", nullable = false) private Garden garden; }
下面的代码假定双向关系。 否则,在完全描述任何儿童
Plant
之前,您需要了解您的Garden.id
Garden garden = new Garden("Oak Grove"); Plant plant = new Plant("Cherry Tomato") plant.setGarden(garden); //don't forget to set the parent on the child garden.addPlant(plant); gardenManager.save(garden);
Yogesh Sakurikar was close, but the bi-directional
@JoinColumn
was a bit off. Below you will see how to join bidirectionally or mono-riectionally@Entity(name = "GARDEN") public class Garden { @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(name = "NAME", nullable = false) private String name; // "Oak Grove" // use this if you don't want a bi-directional relationship // @OneToMany // @JoinColumn(name = "ID", referencedColumnName="GARDEN_ID") // private List<Plant> plants; // use this if you want it bi-directional @OneToMany(fetch = FetchType.LAZY, mappedBy = "garden") private Set<Plant> plants; } @Entity(name = "PLANT") public class Plant { @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(name = "NAME", nullable = false) private String name; // "Cherry Tomato" // use this if you don't want a bi-directional relationship // @Column(name="GARDEN_ID") // private long gardenId; // use this if you want a bi-directional relationship @ManyToOne @JoinColumn(name = "GARDEN_ID", referencedColumnName="ID", nullable = false) private Garden garden; }
The code below assumes bi-directional relationship. Otherwise you'd need to know your
Garden.id
before you could fully describe any childPlant
Garden garden = new Garden("Oak Grove"); Plant plant = new Plant("Cherry Tomato") plant.setGarden(garden); //don't forget to set the parent on the child garden.addPlant(plant); gardenManager.save(garden);
相关问答
更多-
有什么问题是以下几点: @OneToMany(fetch = FetchType.LAZY) @JoinColumn(name="idEmployees") public List
getTasks() { return tasks; } 这有两个原因是错误的。 @JoinColumn(name="idEmployees")表示:使用名为idEmployees的连接列(即外键)映射此OneToMany。 但连接列未命名为idEmployees。 idEmployees是Employee ... -
你做了很多错事。 一些要点: 您正在使用字段和属性访问。 您必须选择一种样式作为默认样式(然后可以使用AccessType覆盖默认的所需属性)。 @ElementCollection用于嵌入式集合,因此会出现错误。 您应该使用@OneToMany 。 不要忘记将双向关联的一方声明为反向关联(如果是@OneToMany关系,通常是One侧的实体)。 You're doing many things wrong. Some of the points: You're using both field and p ...
-
Yogesh Sakurikar很接近,但双向@JoinColumn有点偏。 您将在下面看到如何双向或单向连接 @Entity(name = "GARDEN") public class Garden { @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(name = "NAME", n ...
-
使用上面的映射,没有创建连接表。 OneToMany不需要连接表,您将在Many侧获得外键列。 这是我在使用您的代码时得到的: create table Person ( id bigint not null, primary key (id) ) create table Relationship ( id bigint not null, personFrom_id bigint, personTo_id bigint, primary key (id) ...
-
努力用注释来描述JPA或Hibernate关系(Struggling to describe JPA or Hibernate relationship using annotations)[2022-01-01]
您可以使用Hibernate过滤器来实现此功能,使用您的位置创建过滤器,并在查询之前将其激活。 (这不符合JPA) 喜欢这个: @Entity class MetaDataInfo { @Column int version; @Column String type; @Column boolean isCurrent; } @Entity @FilterDef(name="lastInfo") VersionedInfo { @Column @Filter(n ... -
在3个属性上添加@Id注释。 如果您的实体不仅仅是一个关系表(它拥有其他属性),我建议使用EmbeddedId you add the @Id annotation on the 3 attributes. If your entity is more than a relation table (it holds additional attributes) I would advise to use an EmbeddedId instead
-
这非常简单: customer.addOrder(order); 这就是你所需要的一切。 这是ORM的原则。 您操纵对象,ORM使用您定义的映射将它们保存在数据库中。 It's extremely simple: customer.addOrder(order); That's all you need. That's the principle of an ORM. You manipulate objects, and the ORM saves them in the database using ...
-
你的配置看起来很好。 我怀疑(虽然显然无法确定没有看到你的代码)你没有设置关系的反面,这是必需的。 您将添加NotificationItem ,如下所示: NotificationItem item = new NotificationItem(); item.setServiceConfig(service); //set the other side of the bi-directional relationship servive.getNotificationItems().add(item); ...
-
默认情况下,单向@OneToMany关系将使用连接表,它将执行操作作为我的问题。 如果您使用JPA2并且不在父级上使用多态,则可以添加@JoinColumn ,这将在子表而不是另一个连接表上创建外键。 然后JPA提供程序将不执行删除并重新插入。 By default, a unidirectional @OneToMany relationship will use a join table, it will perform operation as my question. If you are usin ...
-
我认为用Hibernate映射这个模式是不可能的(至少,只要Customer和Recepient不扩展同一个实体)。 使用以下模式会更容易: ADDRESSES { ID } CUSTOMER { ID ADDRESS_ID } RECIPIENT { ID ADDRESS_ID } class Customer { @OneToOne(fetch=FetchType.EAGER, orphanRemoval = true, cascade = { javax.persisten ...