2021-07-28

Archived: JPA JoinColumn vs mappedBy

 





JPA JoinColumn vs mappedBy



https://stackoverflow.com/a/53984572

I disagree with the accepted answer here by Óscar López. That answer is inaccurate!

It is NOT @JoinColumn which indicates that this entity is the owner of the relationship. Instead, it is the @ManyToOne annotation which does this (in his example).

The relationship annotations such as @ManyToOne@OneToMany and @ManyToMany tell JPA/Hibernate to create a mapping. By default, this is done through a seperate Join Table.


@JoinColumn

The purpose of @JoinColumn is to create a join column if one does not already exist. If it does, then this annotation can be used to name the join column.


MappedBy

The purpose of the MappedBy parameter is to instruct JPA: Do NOT create another join table as the relationship is already being mapped by the opposite entity of this relationship.



Remember: MappedBy is a property of the relationship annotations whose purpose is to generate a mechanism to relate two entities which by default they do by creating a join table. MappedBy halts that process in one direction.

The entity not using MappedBy is said to be the owner of the relationship because the mechanics of the mapping are dictated within its class through the use of one of the three mapping annotations against the foreign key field. This not only specifies the nature of the mapping but also instructs the creation of a join table. Furthermore, the option to suppress the join table also exists by applying @JoinColumn annotation over the foreign key which keeps it inside the table of the owner entity instead.

So in summary: @JoinColumn either creates a new join column or renames an existing one; whilst the MappedBy parameter works collaboratively with the relationship annotations of the other (child) class in order to create a mapping either through a join table or by creating a foreign key column in the associated table of the owner entity.

To illustrate how MapppedBy works, consider the code below. If MappedBy parameter were to be deleted, then Hibernate would actually create TWO join tables! Why? Because there is a symmetry in many-to-many relationships and Hibernate has no rationale for selecting one direction over the other.

We therefore use MappedBy to tell Hibernate, we have chosen the other entity to dictate the mapping of the relationship between the two entities.

@Entity
public class Driver {
    @ManyToMany(mappedBy = "drivers")
    private List<Cars> cars;
}

@Entity
public class Cars {
    @ManyToMany
    private List<Drivers> drivers;
}

Adding @JoinColumn(name = "driverID") in the owner class (see below), will prevent the creation of a join table and instead, create a driverID foreign key column in the Cars table to construct a mapping:

@Entity
public class Driver {
    @ManyToMany(mappedBy = "drivers")
    private List<Cars> cars;
}

@Entity
public class Cars {
    @ManyToMany
    @JoinColumn(name = "driverID")
    private List<Drivers> drivers;
}










2021-07-25

紧急公关让人印象深刻的台词

 

Source URL: https://movie.douban.com/review/13188894/


本剧让人印象深刻的台词

悦妙曦 评论 紧急公关 2021-02-04 10:05:36
这篇剧评可能有剧透

1.一个真正懂得生活疾苦的人,也一定是一个慈悲的人。

2.成年人的世界是有多面性的。

3.复仇这盘菜,放凉了才好吃。

4.对于很多人来说,失去自由远比不上被人侮辱更加痛苦。

5.真相,只有百分之百确凿的时候才有意义。不然它打着真相的幌子有可能成为伤害他人的利器。

6.有时候,我们想不通一件事往往是因为我们太局限在自己过往的经历中了,我们不知道未来会是什么样子的。

7.在这个世界上,挫折往往不能打倒一个人,打倒一个人的往往都是顽固的观念。

8.一个人出现精神分裂的前兆就是相信自己对工作特别重要。

9.一个不愿意放弃别人的人,一定是一个有人情味的人。

10.我的能力,就是尽我所能,让大家看到事情的真相。

11.我对那些凝视过深渊依然不放弃的人充满了尊重。

12.表面平静,不代表伤害得不够深。

13.最伤元气的就是离婚官司,因为你不得不将枪对准曾经最爱的人。

14.推脱自己的最好方法就是从自己身上找原因。

15.婚姻不只是有感情,更重要的是博弈。

16.但光明背后都有阴影,这就是生存的代价。

17.不是每个女人离开男人都会活不了。

18.年轻是女人的资本,这句话是对女人最大的谎言。

19.老天还真是公平,不论你是当好人还是坏人,它都不会让你的日子好过。

20.人生本如痴人说梦,充满了喧哗与骚动,然而这一切并没有任何意义。

21.想要比别人更多的东西,并不是一件羞耻的事。

22.不管未来发生什么,我们都不要乱了阵脚。

23.不是谁都会为了利益低头的。

24.一个不懂得感恩的人,运气是不会长久的。

25.一步妥协,步步妥协。

26.如果你在乎我的话,我不应该是你的弱点,我应该让你变得更加强大。

27.我也是人啊,也有宕机的时候。

28.真正的爱情,是会让人生出不顾一切的勇气的。

29.你对生活还有不甘心的时候,当然害怕死亡。

30.我以为需要赎罪的只会是有罪的人,可真正有罪的却逍遥法外,无辜的人却要受罚。

31.这就是命运,它凌驾在任何法则之上。

32.我相信爱,不管是一个人对另一个人的爱,还是一个人对世界的爱。爱可以抵抗这个世界的残酷,是唯一可以创造美好奇迹的东西。

33.我希望你能一直按照你的原则做事。

34.过好咱们自己的日子,比什么都强。

35.你只有站在我的角度,才能真正理解我。

36.一个女孩子可以不漂亮,可以不懂事,也可以不温柔,但千万不可以自卑。自卑会让你虚荣虚荣就会让你冒险去脱离正轨,而当你脱离正轨的那一刻起,你就已经输了。终有一天你会发现,你所向往的那些生活,不过都是幻影。

37.一个成熟的人应该先去了解对方,然后依然愿意给他他想要的,这才是真正的爱。

38.逃避一件事情的痛苦要远远大于这件事情本身带来的压力。

39.有些事情,并不是明知结果失败的,就是去了去做它的意义的。

40.你们的道歉,并不是为了求得原谅。

41.只有在极端的事情面前,才能看到平时看不到的人性。

42.既然得不到,至少可以不让人讨厌。

43.到了我们这个年纪,又有几个是容易的呢?

44.解决危机的最好办法,就是承认和正视自己的错误。

45.我愿意为我曾经的错误,承担任何后果。

46.你的伪装,永远都欺骗不了一些人。而这些人,才是你真正在意的人。在这个世界上,只有走正路的人才能获得别人真正的尊重。

47.得不到一个人的爱,当然也得不到一个人的恨。

48.在这个世界上,不是只有表面的输和赢,我更看重我内心的感受,这才是真正有意义的东西。

49.有些感情不是那么浅白,让人一下子就能理解的。当事人都不一定明白,更何况我们这些旁观者?

50.对于一个撰稿人而言,越是擅长使用语言,越明白语言是多么的苍白和无力。

51.人们总是这样,总是在防止自己受到伤害,但是对于有些人来说,伤害了别人,那种负罪感才是最折磨人的。

52.最爱的人,未必是命中注定那个陪伴我们一生的人,但是我们爱过的每一个人,都让我们的自身变得完整,也都只有我们面对生活的勇气。

53.人生而平等,原来只是一句愚弄人的谎话。

54.有些人生而甜蜜欢畅,有些人生而无尽夜长。

55.在这个世界上,不是什么人都有能力去主动选择自己的悲剧的。

56.有些人就算是失败了,也比你体面。

57.公关,如果只考虑客户利益,不考虑公众利益,那还有什么意义呢?

58.无论你是记者,抑或是是其他可以影响舆论的人,或者是坐在电脑桌前的网民们,你们发出的每一句话,你们写下的每一篇报道,甚至于你们在电脑桌前敲下的每一行评论,都有可能把当事人推进无尽的深渊。在这个全民都是自媒体的时代里面,我们每个人手里都有一把无形的刀,可以伤害任何一个人。不利用这把刀作恶,应该是我们每一个人的底线。

59.但当你面对被你伤害人的时候,你才真正明白你赢的有多么地空虚。

60.一个知道自己有罪的人,面对心爱的人,是多么的无力。

61.没人可以拯救我们,只有我们自己。赎罪是卸下包袱的唯一方法。

62.以前,我一直以为这个世界欠我的,但到了现在我才明白,它已经把最好的全都给我了。

63.我这个人最不喜欢告别的场面。

64.人的自我完善,都是在与他人的互动中完成的。

65.我从他们身上感受到的温暖和关爱,远远多于我为他们所做的。

66.我不想说有缘再见的话,大部分从我们生活中离开的人都不会再见。我希望他们只是把我当成人生中的过客,走好接下来的路。

(欢迎大家补充,谢谢!)










2021-07-23

org.springframework.orm.jpa.JpaSystemException: identifier of an instance was altered to null


my case was exception throw during selection(findAll()) within a loop.

what i did was trace down the instance within the loop, identify where i changed the ID previously and patch accordingly.









2021-07-09

multithreads - pcdrssd.p5x, RAM consumption - pcdrmemory2.p5x

 

multithreads
pcdrssd.p5x



consumed more than 10GB, holding time keep increasing, and release the RAM after that.
pcdrmemory2.p5x




Found relevant info:
  1. https://www.dell.com/community/Windows-General/PCDr/td-p/3569189
  2. https://www.winhelponline.com/blog/pc-doctor-module-high-cpu-memory-and-disk-usage-and-slowdown/



“PC-Doctor Module” High CPU, Memory, Disk Usage and Slowdown

Occasionally, your system may slow down to a crawl due to the PC-Doctor Module process that runs in the background. When this happens, it can take several seconds to open the Task Manager or any program.

The Task Manager may show that a process named PC-Doctor Module is occupying 100% of CPU and a very high amount of RAM. You may be wondering if PC-Doctor Module is a virus, Malware, or a PUA.

dell pc-doctor module 100% cpu and memory usage


When you right-click on PC-Doctor Module and click Go to details to find the executable file name of the application, you’ll find that the executable file path looks like the following, and runs under NT AUTHORITY\SYSTEM (LocalSystem) account:

C:\Program Files\Dell\SupportAssistAgent\PCDr\SupportAssist\6.0.7193.611\pcdrmemory2.p5x" run -e -lang en -cust dell -var dsc -bd "C:\ProgramData\PCDr\7193" -engineClientPid

This happens in Dell computers that ship with the Dell SupportAssist diagnostics (a.k.a. Dell SupportAssist remediation services) utility.

Dell SupportAssist – Scheduled hardware scan and optimization tasks

PC-Doctor Module is a component of Dell SupportAssist. Dell SupportAssist keeps your PC up to date and running at its best with recommended software and driver updates. It also helps resolve issues quickly by detecting common problems and sending issue details to Dell Technical Support agents on your behalf.

The Dell SupportAssist tool periodically runs a hardware scan and optimization tasks. When it runs the hardware scan, the following components are analyzed:

  • Memory, CPU, Hard Drive, DVD-RW Drive, HD Audio Controller, PCI Bridge, PCI Bus, Hub, Network Card, USB Composite, Mouse, USB.

It does a SMART Short Self Test, Linear Read test, Targeted Read test, CPU stress test, among other tests.

  • During this process, the CPU, Memory, and Disk usage would spike up to 100% for a few minutes.

You can open the SupportAssist tool from the Start menu.

dell pc-doctor module 100% cpu and memory usage

SupportAssist — Scheduled Scans

The results of the previous hardware scans and optimization tasks would be available under the History tab of the Dell SupportAssist utility.




Click on the gear icon at the top right corner of the window, and click Settings.

By default, the Hardware scans are scheduled to run monthly once.



In the Settings page, you can disable the scheduled scans and optimizations by unchecking Turn on automatic scans and optimizations at: checkbox.

Alternatively, you can schedule a different time for the tasks to run. You may want to run the tasks after office hours so that you don’t face any performance bottlenecks when you’re working.

If you choose to disable the automatic scans, then you can manually run the scans at your preferred time or intervals via the Home tab.

Hardware scans can be extremely beneficial. You can make informed decisions from these scan results — e.g., it informs you in advance if a hardware component (i.e., the hard disk drive) is about to fail so that you can replace the necessary hardware proactively.
































2021-06-28

Is working - while create function: ERROR 1418 (HY000) & ERROR 1267 (HY000)

 



SHOW VARIABLES LIKE '%char%';




ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)



Source URL: https://stackoverflow.com/a/26015334

  1. Execute the following in the MySQL console:

    SET GLOBAL log_bin_trust_function_creators = 1;






ERROR 1267 (HY000): Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='


drop table

and recreate table with 

CREATE DATABASE new_table DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci;



2021-06-18

Ïë¼ûÄã





in Notepad ++
open new doc

change encoding to: ANSI

paste

Ïë¼ûÄã

save doc
then change encoding to GB2312




























ANSI和GB2312的区别

我叫农 2018-06-25 16:58:17  7504  收藏 3
分类专栏: 编码
这几天工作中用到不少字符集,Unicode、utf-8、GB2312等,但是在windows命令行里敲notepad进入文本编辑页面。保存时需要选择编码方式,但是不存在GB,却有ANSI,于是纳闷,回来一查,才恍然大悟:原来在简体中文系统下,ANSI 编码代表 GB2312 编码。

  为使计算机支持更多语言,通常使用 0x80~0xFF 范围的 2 个字节来表示 1 个字符。比如:汉字 ‘中’ 在中文操作系统中,使用 [0xD6,0xD0] 这两个字节存储。

  不同的国家和地区制定了不同的标准,由此产生了 GB2312, BIG5, JIS 等各自的编码标准。这些使用 2 个字节来代表一个字符的各种汉字延伸编码方式,称为 ANSI 编码。在简体中文系统下,ANSI 编码代表 GB2312 编码,在日文操作系统下,ANSI 编码代表 JIS 编码。

  不同 ANSI 编码之间互不兼容,当信息在国际间交流时,无法将属于两种语言的文字,存储在同一段 ANSI 编码的文本中。











clear "$Recycle.Bin" in external hard drive

 

Googled: clear "$Recycle.Bin" in external hard drive

Found Source URL: https://superuser.com/a/564461


The $RECYCLE.BIN directory can be deleted from Windows command line rmdir /q /s C:\$RECYCLE.BIN as described in the first answer to this similar question, although as a system virtual folder care should be taken. Also, it will get recreated upon deletion of files from the drive containing it.
















2021-06-04

Generic ParameterizedType checking throw exception.

 
Generic Exception:
Unexpected case, types[0] NOT instanceof Class



Changed from:
public class ImplementClass<Entity> extends AbstractClass<Entity> {
}

to:
public class ImplementClass extends AbstractClass<Entity> {
}

2021-05-06

Download m3u8 with .ts files as mp4

 

Googled: download m3u8

https://www.google.com/search?q=download+m3u8&oq=download+m3u8&aqs=chrome..69i64j0l9.5315j0j7&sourceid=chrome&ie=UTF-8




https://chrome.google.com/webstore/detail/m3u8-online-video-extract/fcpefnjbneopahdnhdhahbhoccipdmdm






Convert ts files to mp4

ffmpeg -i ts_file_path -acodec copy -vcodec copy -f mp4 path+name.mp4

Projects from:

https://github.com/Momo707577045/m3u8-downloader

Thank you for sharing that







2021-04-27

Hyphen vs Dash vs Minus

 
Hyphen - Wikipedia

The hyphen is sometimes confused with dashes (figure dash en dash em dash horizontal bar ), which are longer and have different uses, or with the minus sign , which is also longer and more vertically centred in some typefaces.










2021-04-26

Year in short... 'yr

 
formatting - Can I use an abbreviated two-digit format for year in a resume? - Writing Stack Exchange




According to this source the correct symbol to abbreviate year using two digits is an apostrophe:

When abbreviating a year, remove the first two numbers and indicate the omission by using an apostrophe:

  • 2009 becomes ’09 (not ‘09)
  • 2010 becomes ’10 (not ‘10)
  • 2525 becomes ’25 (if we're still alive)

Notice I said apostrophe, not single opening quote.

You could use whatever you want on your resume, your choices will make your resume more or less effective, also depending on who will read and how you articulate different solutions for presentation.








2021-04-21

AutoHotkey & Java: Calendar will take your given milliseconds as UTC, then offset with your timezone when you do: Calendar.getTime().

 
Senarior:
Come across to integrate AutoHotkey & Java.

getting timestamp in milliseconds from AutoHotkey, then pass into Java process.


Found out:
Calendar will offset your milliseconds(a or b, which is UTC timstamp) with your timezone.


Given as below:

a = Calendar.getTime()

&

b = System.currentTimeMillis()

&

EpochTimestamp_Now_UTC := A_NowUTC
EnvSub, EpochTimestamp_Now_UTC, 19700101000000, Seconds
Milliseconds_Now_UTC := EpochTimestamp_Now_UTC * 1000 + A_MSec
c := Milliseconds_Now_UTC 


Billson@20210415_pm121738 : System.currentTimeMillis(); = Calendar.getInstance().getTimeInMillis(); = A_NowUTC in EpochTimestamp = EpochTimestamp_Now_UTC

Three above(a, b, c) are identical, and they will hold UTC timestamp.

BUT

When u pass back into
Calendar calTmp = Calendar.getInstance();
calTmp.setTimeInMillis(milliseconds);

Sysout#1
calTmp.setTimeInMillis(a);
System.out.println(calTmp.getTime());

Sysout#2
calTmp.setTimeInMillis(c);
System.out.println(calTmp.getTime());

Sysout#1 & Sysout#2 will show your localtime.

Calendar will offset your milliseconds(a or b, which is UTC timstamp) with your timezone.
But not sure happen this offset within which part.










2021-04-19

Warning message, Failed to scan (java.io.FileNotFoundException) from: org.apache.tomcat.util.scan.StandardJarScanner


At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.|org.apache.jasper.servlet.TldScanner



Found below config is working:



Reference URL: https://stackoverflow.com/a/50743050


you can add  server.tomcat.additional-tld-skip-patterns=*.jar in application.propertiesfile or  server: tomcat: additional-tld-skip-patterns: '*.jar' in application.ymlfile.

Refer : The Jar Scanner ComponentThe official reply.









 

Google Referrals