kafka - 可以将python程序连接到hadoop集群外的Kafka吗?(kafka - can python program connect to Kafka outside hadoop cluster?)
我正在学习卡夫卡,需要一些建议。
我想编写一个python程序,它读取文件并将数据作为生产者写入Kafka。 Kafka在Hadoop集群中设置,Python将在Hadoop集群之外运行。
可以从外面连接吗? 我需要为python安装Kafka库吗? 我该如何安装?
I would like to write a python program which reads a file and writes the data to Kafka as a producer. Kafka is setup in the Hadoop cluster and Python will be running outside Hadoop cluster.
is it possible to connect from outside? do i need to install Kafka libraries for python? how do I need to install?
原文:https://stackoverflow.com/questions/47850387
最满意答案
我会尝试使用以下命令打开hibernate SQL日志:
org.hibernate.SQL=DEBUG
看起来你正试图在某处删除GeoFence实体,并且GeoFenceDevice上的FK正在抱怨。
After several hours I found a solution for my problem !
Actually the fact of deleting a row from an association of 2 entities is called an
orphanRemoval
in Entity RelationshipsSo the changes I made in code are :
Device entity :
@OneToMany(fetch = FetchType.LAZY, mappedBy = "device", orphanRemoval=true)
Geofence entity :
@OneToMany(fetch = FetchType.LAZY, mappedBy = "geofence", orphanRemoval=true) private List<GeofenceDevice> listGeofenceDevice;
相关问答
更多-
在hibernate中一对多映射ConstraintViolationException(One to many mapping ConstraintViolationException in hibernate)[2023-01-05]
在Show Pojo中,您已将threaterId定义为int,但它应该是Threater pojo的对象。 在hibernate中,如果你想使用O2m关系,你必须在pojo中定义相同的。 所以,为此你必须修改你的节目pojo as public class Shows{ private int showId; private String showType; @OneToMany @JoinColumn(name="theaterId") private Threater theater; //get ... -
使用constraintviolationexception进行Hibernate批量更新(Hibernate batch updates with constraintviolationexception)[2023-08-26]
这是我的解决方案: private void saveBatch() { StatelessSession session = sessionFactory.openStatelessSession(); Transaction tx = session.beginTransaction(); try { for (Object t : batchList) { session.insert(t); } ... -
查看更好(并检查Hibernate代码)似乎是query.list()(在stacktrace中查询successl缺失)和查询执行前自动刷新运行的问题。 尝试将flushMode更改为COMMIT或在查询之前执行session.flush()。 对于这种工作,你看春季批次吗? Looking better (and checking Hibernate code) seems a problem during query.list() (in stacktrace Query successfull is ...
-
如何在hibernate中处理ConstraintViolationException(How to handle ConstraintViolationException in hibernate)[2023-07-03]
这个链接解决了我的问题: 在JBoss AS 7中捕获PersistenceException或ConstraintViolationException 然后作为一种解决方法,我创建了一个电子邮件验证器,并在我正在验证的字段中添加了一个f:验证器。 @FacesValidator("emailValidator") public class EmailValidator implements Validator { public void validate(FacesContext context, UI ... -
Thanks Andy Ying for your suggestions. The foreign key was not null in the child table. I resolved my issue by adding not-null="tru ... -
如果您已在子映射中正确映射父类,则Hiberate cascade选项会使用外键插入子对象。 如果您没有在子映射中映射父类,而是将其映射为Integer reference_id ,则将使用单独的更新查询更新外键: update question_answer set reference_id = ? where question_answer_id = ? 如果您不能在子映射中指定父类对象,则可以使用变通方法。 您可以将reference_id设置为null (在表上),并且您需要设置referenc ...
-
更新时休眠多对多ConstraintViolationException(Hibernate Many-to-many ConstraintViolationException while update)[2022-03-26]
它没有级联限制 SessionFactory sf = HibernateUtil.getSessionFactory(); Session session = sf.openSession(); session.beginTransaction(); session.delete(photo); session.getTransaction().commit(); session.close(); 在Photo中使用这样的映射: @ManyToMany(fetch = FetchType.EAGER, ... -
JPA hibernate插入行导致ConstraintViolationException(JPA hibernate insert row cause ConstraintViolationException)[2023-02-19]
我解决了我的问题。 我在DB中顺序插入了数字。为此目的使用序列是必要的。 I resolved my issue. i inserted exactly the numbers sequencially in DB It is neccessary to use the sequence for this purpose. -
删除时Hibernate ConstraintViolationException(Hibernate ConstraintViolationException on delete)[2023-08-19]
我会尝试使用以下命令打开hibernate SQL日志: org.hibernate.SQL=DEBUG 看起来你正试图在某处删除GeoFence实体,并且GeoFenceDevice上的FK正在抱怨。 After several hours I found a solution for my problem ! Actually the fact of deleting a row from an association of 2 entities is called an orphanRemoval ... -
无法删除或更新父行ConstraintViolationException(Cannot delete or update a parent row ConstraintViolationException)[2023-09-19]
尝试使用entityManager.createNativeQuery() 。 您不能使用createQuery()因为该表应作为Java代码中的实体存在。 此外,您需要使用确切的SQL格式。 String query = "DELETE FROM USER_PHONE WHERE user_id=?1"; try{ Query q = entityManager.createNativeQuery(query); q.setParameter(1,id); ...