问:
Reloading table view data (Collection View) reloads to incorrect Section after Callback
I have a collection view nested inside of a table view that is reloading the data to the wrong section after I make a call back.  I'm not sure why this is happening so any help would be appreciated.  I have it broken down into three files: TableViewController, CollectionViewCell and TableViewCell.  Table view cell makes the call back to the table view controller in order to load and display ads; after this when the reload on the view controller is made it's reloading the data to the wrong sections:

TableViewController

```<code>import UIKit
import GoogleMobileAds

var data = [ThemesData(sectionType: "General", Themes: ["Themes/General/T001AAAK.png"]),

            ThemesData(sectionType: "Plain", Themes: [
                "Themes/Plain/T001AAAB.png", "Themes/Plain/T002AAAA.png", "Themes/Plain/T003AAAH.png", "Themes/Plain/T004AAAC.png", "Themes/Plain/T006AAAD.png", "Themes/Plain/T008AAAE.png", "Themes/Plain/T010AAAF.png", "Themes/Plain/T012AAAG.png", "Themes/Plain/T014AAAI.png", "Themes/Plain/T016AAAJ.png"
            ])
]

class ThemesViewController: UIViewController, GADFullScreenContentDelegate {

    //Outlets
    @IBOutlet weak var tableView: UITableView!

    //Constants
    let defaults = UserDefaults.standard

    // Variables
    var myTheme: String = ""
    private var rewardedInterstitialAd: GADRewardedInterstitialAd?

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.navigationItem.hidesBackButton = false
        self.navigationController?.setNavigationBarHidden(false, animated: true)

        GADRewardedInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/6978759866",
                                       request: GADRequest()) { [self] ad, error in
            if let error = error {
                return print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
            }

            self.rewardedInterstitialAd = ad
            rewardedInterstitialAd?.fullScreenContentDelegate = self

        }
    }

    func showAd() {
        guard let rewardedInterstitialAd = rewardedInterstitialAd else {
            return print("Ad wasn't ready.")
        }

        rewardedInterstitialAd.present(fromRootViewController: self) { [self] in
            let reward = rewardedInterstitialAd.adReward
            // Set new Theme
            defaults.set(myTheme, forKey: "mTheme")
            print(myTheme)
            // set new Font
            var tFont = myTheme.suffix(8)
            tFont = tFont.prefix(4)
            print(tFont)
            defaults.set(tFont, forKey: "mFont")
            // reload the themes view controller
        }
    }

    /// Tells the delegate that the ad dismissed full screen content.
    func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
        print(data)
        tableView.reloadData()
        GADRewardedInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/6978759866",
                                       request: GADRequest()) { [self] ad, error in
            if let error = error {
                return print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
            }

            self.rewardedInterstitialAd = ad
            rewardedInterstitialAd?.fullScreenContentDelegate = self
        }
    }

}

extension ThemesViewController: UITableViewDelegate, UITableViewDataSource {

    public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 200
    }

    public func numberOfSections(in tableView: UITableView) -> Int {
        return data.count
    }

    public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return data[section].sectionType
    }

    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ThemeTableViewCell
        cell.collectionView.tag = indexPath.section
        guard let productsCell = cell as? ThemeTableViewCell else {
            return cell
        }

        productsCell.didSelectItemAction = { [weak self]  String in
            self!.myTheme = String
            self!.adAlert()
        }
        return cell
    }

    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    }

    public func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        view.tintColor = .colorFromHex("a5d7fa")
        let header = view as! UITableViewHeaderFooterView
        header.textLabel?.textColor = UIColor.black
    }

    func adAlert() {
        let showAlert = UIAlertController(title: "Unlock Themes", message: nil, preferredStyle: .alert)
        let image = UIImage(systemName: "paintbrush")
        showAlert.addImage(image: image!)

        showAlert.addAction(UIAlertAction(title: "Watch Video", style: .default, handler: { action in
            // Show Ad & update
            self.showAd()
        }))
        showAlert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { action in
        }))
        self.present(showAlert, animated: true, completion: nil)
    }

    func setFont() {
        // set new Font
        var tFont = myTheme.suffix(8)
        tFont = tFont.prefix(4)
        print(tFont)
        defaults.set(tFont, forKey: "mFont")
        var mySubstring = myTheme.suffix(11)
    }
}
</code>```

CollectionViewCell

```<code>import UIKit

class ThemeCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var images: UIImageView!
    @IBOutlet weak var padlock: UIImageView!
}
</code>```

TableViewCell

```<code>import Foundation
import UIKit
import GoogleMobileAds

class ThemeTableViewCell: UITableViewCell {

    //Outlets
    @IBOutlet weak var collectionView: UICollectionView!

    //Constants
    let defaults = UserDefaults.standard

    //Variables
    var myTheme = ""
    private var rewardedInterstitialAd: GADRewardedInterstitialAd?
    var didSelectItemAction: ((String) -> Void)?
    var retVal: String = ""

    override func awakeFromNib() {
        super.awakeFromNib()

        // Initialization code
        collectionView.delegate = self
        collectionView.dataSource = self
        myTheme = defaults.string(forKey: "mTheme")!
    }
}

extension ThemeTableViewCell: UICollectionViewDelegate, UICollectionViewDataSource {

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return data[collectionView.tag].Themes.count
    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
        let tCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ThemeCollectionViewCell

        // check to see if this image requires a rewarded ad to unlock
        if tCell.padlock.isHidden == false {
            // we need a rewarded vide
            print(data[collectionView.tag].Themes[indexPath.item])
            let replaced = data[collectionView.tag].Themes[indexPath.item].replacingOccurrences(of: "T0", with: "I0")
            didSelectItemAction?(replaced)
            collectionView.reloadData()
        } else {
            // set new theme
            print(data[collectionView.tag].Themes[indexPath.item])
            let replaced = data[collectionView.tag].Themes[indexPath.item].replacingOccurrences(of: "T0", with: "I0")
            defaults.set(replaced, forKey: "mTheme")
            myTheme = defaults.string(forKey: "mTheme")!

            // set new Font
            var tFont = myTheme.suffix(8)
            tFont = tFont.prefix(4)
            print(tFont)
            defaults.set(tFont, forKey: "mFont")
            var mySubstring = myTheme.suffix(11)
            collectionView.reloadData()
        }
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ThemeCollectionViewCell
        cell.images.image = UIImage(named: data[collectionView.tag].Themes[indexPath.row])
        print(data[collectionView.tag].Themes[indexPath.item])
        print(data[collectionView.tag].sectionType)
        let myData = data[collectionView.tag].Themes[indexPath.item]
        if data[collectionView.tag].sectionType == "General" {
            cell.padlock.isHidden = true
        } else {
            cell.padlock.isHidden = false
        }
        let replaced = myData.replacingOccurrences(of: "T0", with: "I0")

        if replaced == myTheme {
            cell.images?.layer.borderWidth = 4.5
            cell.images?.layer.borderColor = UIColor.red.cgColor
            cell.images?.clipsToBounds = true
            cell.padlock.isHidden = true
        } else {
            cell.images?.layer.borderWidth = 0.0
            cell.images?.layer.borderColor = UIColor.white.cgColor
            cell.images?.clipsToBounds = true
            cell.padlock.isHidden = false
        }
        if data[collectionView.tag].sectionType == "General" {
            cell.padlock.isHidden = true
        } else {
            if cell.images?.layer.borderColor == UIColor.red.cgColor {
                cell.padlock.isHidden = true
            } else {
                cell.padlock.isHidden = false
            }
        }
        return cell
    }
}
</code>```

Body:
I have a collection view nested inside of a table view that is reloading the data to the wrong section after I make a call back.  I'm not sure why this is happening so any help would be appreciated.  I have it broken down into three files: TableViewController, CollectionViewCell and TableViewCell.  Table view cell makes the call back to the table view controller in order to load and display ads; after this when the reload on the view controller is made it's reloading the data to the wrong sections:

TableViewController

import UIKit
import GoogleMobileAds

var data = [ThemesData(sectionType: "General", Themes: ["Themes/General/T001AAAK.png"]),

            ThemesData(sectionType: "Plain", Themes: [
                "Themes/Plain/T001AAAB.png", "Themes/Plain/T002AAAA.png", "Themes/Plain/T003AAAH.png", "Themes/Plain/T004AAAC.png", "Themes/Plain/T006AAAD.png", "Themes/Plain/T008AAAE.png", "Themes/Plain/T010AAAF.png", "Themes/Plain/T012AAAG.png", "Themes/Plain/T014AAAI.png", "Themes/Plain/T016AAAJ.png"
            ])
]

class ThemesViewController: UIViewController, GADFullScreenContentDelegate {

    //Outlets
    @IBOutlet weak var tableView: UITableView!

    //Constants
    let defaults = UserDefaults.standard

    // Variables
    var myTheme: String = ""
    private var rewardedInterstitialAd: GADRewardedInterstitialAd?

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.navigationItem.hidesBackButton = false
        self.navigationController?.setNavigationBarHidden(false, animated: true)

        GADRewardedInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/6978759866",
                                       request: GADRequest()) { [self] ad, error in
            if let error = error {
                return print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
            }

            self.rewardedInterstitialAd = ad
            rewardedInterstitialAd?.fullScreenContentDelegate = self

        }
    }

    func showAd() {
        guard let rewardedInterstitialAd = rewardedInterstitialAd else {
            return print("Ad wasn't ready.")
        }

        rewardedInterstitialAd.present(fromRootViewController: self) { [self] in
            let reward = rewardedInterstitialAd.adReward
            // Set new Theme
            defaults.set(myTheme, forKey: "mTheme")
            print(myTheme)
            // set new Font
            var tFont = myTheme.suffix(8)
            tFont = tFont.prefix(4)
            print(tFont)
            defaults.set(tFont, forKey: "mFont")
            // reload the themes view controller
        }
    }

    /// Tells the delegate that the ad dismissed full screen content.
    func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
        print(data)
        tableView.reloadData()
        GADRewardedInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/6978759866",
                                       request: GADRequest()) { [self] ad, error in
            if let error = error {
                return print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
            }

            self.rewardedInterstitialAd = ad
            rewardedInterstitialAd?.fullScreenContentDelegate = self
        }
    }

}

extension ThemesViewController: UITableViewDelegate, UITableViewDataSource {

    public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 200
    }

    public func numberOfSections(in tableView: UITableView) -> Int {
        return data.count
    }

    public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return data[section].sectionType
    }

    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ThemeTableViewCell
        cell.collectionView.tag = indexPath.section
        guard let productsCell = cell as? ThemeTableViewCell else {
            return cell
        }

        productsCell.didSelectItemAction = { [weak self]  String in
            self!.myTheme = String
            self!.adAlert()
        }
        return cell
    }

    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    }

    public func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        view.tintColor = .colorFromHex("a5d7fa")
        let header = view as! UITableViewHeaderFooterView
        header.textLabel?.textColor = UIColor.black
    }

    func adAlert() {
        let showAlert = UIAlertController(title: "Unlock Themes", message: nil, preferredStyle: .alert)
        let image = UIImage(systemName: "paintbrush")
        showAlert.addImage(image: image!)

        showAlert.addAction(UIAlertAction(title: "Watch Video", style: .default, handler: { action in
            // Show Ad & update
            self.showAd()
        }))
        showAlert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { action in
        }))
        self.present(showAlert, animated: true, completion: nil)
    }

    func setFont() {
        // set new Font
        var tFont = myTheme.suffix(8)
        tFont = tFont.prefix(4)
        print(tFont)
        defaults.set(tFont, forKey: "mFont")
        var mySubstring = myTheme.suffix(11)
    }
}

CollectionViewCell

import UIKit

class ThemeCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var images: UIImageView!
    @IBOutlet weak var padlock: UIImageView!
}

TableViewCell

import Foundation
import UIKit
import GoogleMobileAds

class ThemeTableViewCell: UITableViewCell {

    //Outlets
    @IBOutlet weak var collectionView: UICollectionView!

    //Constants
    let defaults = UserDefaults.standard

    //Variables
    var myTheme = ""
    private var rewardedInterstitialAd: GADRewardedInterstitialAd?
    var didSelectItemAction: ((String) -> Void)?
    var retVal: String = ""

    override func awakeFromNib() {
        super.awakeFromNib()

        // Initialization code
        collectionView.delegate = self
        collectionView.dataSource = self
        myTheme = defaults.string(forKey: "mTheme")!
    }
}

extension ThemeTableViewCell: UICollectionViewDelegate, UICollectionViewDataSource {

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return data[collectionView.tag].Themes.count
    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
        let tCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ThemeCollectionViewCell

        // check to see if this image requires a rewarded ad to unlock
        if tCell.padlock.isHidden == false {
            // we need a rewarded vide
            print(data[collectionView.tag].Themes[indexPath.item])
            let replaced = data[collectionView.tag].Themes[indexPath.item].replacingOccurrences(of: "T0", with: "I0")
            didSelectItemAction?(replaced)
            collectionView.reloadData()
        } else {
            // set new theme
            print(data[collectionView.tag].Themes[indexPath.item])
            let replaced = data[collectionView.tag].Themes[indexPath.item].replacingOccurrences(of: "T0", with: "I0")
            defaults.set(replaced, forKey: "mTheme")
            myTheme = defaults.string(forKey: "mTheme")!

            // set new Font
            var tFont = myTheme.suffix(8)
            tFont = tFont.prefix(4)
            print(tFont)
            defaults.set(tFont, forKey: "mFont")
            var mySubstring = myTheme.suffix(11)
            collectionView.reloadData()
        }
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ThemeCollectionViewCell
        cell.images.image = UIImage(named: data[collectionView.tag].Themes[indexPath.row])
        print(data[collectionView.tag].Themes[indexPath.item])
        print(data[collectionView.tag].sectionType)
        let myData = data[collectionView.tag].Themes[indexPath.item]
        if data[collectionView.tag].sectionType == "General" {
            cell.padlock.isHidden = true
        } else {
            cell.padlock.isHidden = false
        }
        let replaced = myData.replacingOccurrences(of: "T0", with: "I0")

        if replaced == myTheme {
            cell.images?.layer.borderWidth = 4.5
            cell.images?.layer.borderColor = UIColor.red.cgColor
            cell.images?.clipsToBounds = true
            cell.padlock.isHidden = true
        } else {
            cell.images?.layer.borderWidth = 0.0
            cell.images?.layer.borderColor = UIColor.white.cgColor
            cell.images?.clipsToBounds = true
            cell.padlock.isHidden = false
        }
        if data[collectionView.tag].sectionType == "General" {
            cell.padlock.isHidden = true
        } else {
            if cell.images?.layer.borderColor == UIColor.red.cgColor {
                cell.padlock.isHidden = true
            } else {
                cell.padlock.isHidden = false
            }
        }
        return cell
    }
}


来源: stackexchange

问:
Google Sheets - Smooth Line Chart - flip the axis
Id like this chart to show the series Line date 1,2,&3 on the X-axis and Thing on the Y-axis. What is the chart setup to do this?

Link to Doc

ContentLicense: CC BY-SA 4.0


问:
how to set up varest to call from json in url
Im quite new to using networking systems such as Varest for Json / Unreal.

I have been stuck on this for a few days now, and trying different varying outcomes but i keep coming back to this.

unreal blueprint photo

I am trying to select the "_links" in the URL and get unreal to process the account / Href key with my own.

I Read that there are diffrent types of Json - nested, High level and regular and understand these work like a Text format of Excel file.

I am wondering if this format is High level and how would I go about setting varest to read and process these strings?

https://horizon-testnet.stellar.org/ < -- URL has values

```<code>[2022.12.21-01.30.25:460][345]LogVaRest: Warning: UVaRestJsonObject::GetArrayField(277): No field with name _links of type Array

</code>```

Body:
Im quite new to using networking systems such as Varest for Json / Unreal.

I have been stuck on this for a few days now, and trying different varying outcomes but i keep coming back to this.

unreal blueprint photo

I am trying to select the "_links" in the URL and get unreal to process the account / Href key with my own.

I Read that there are diffrent types of Json - nested, High level and regular and understand these work like a Text format of Excel file.

I am wondering if this format is High level and how would I go about setting varest to read and process these strings?

https://horizon-testnet.stellar.org/ < -- URL has values

[2022.12.21-01.30.25:460][345]LogVaRest: Warning: UVaRestJsonObject::GetArrayField(277): No field with name _links of type Array


问:
How to catch Mailchimp validation error (mce-inline-error)
this is my email form

```<code><form action="https://gmail.us11.list-manage.com/subscribe/post?u=XXXXXX" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll" style="display: flex;flex-direction: row;">
        <div class="mc-field-group">
            <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
            <span id="mce-EMAIL-HELPERTEXT" class="helper_text"></span>
        </div>
        <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_fb16c0b54b243c41cf0ba431c_6cbe3da72c" tabindex="-1" value=""></div>
        <div class="optionalParent">
            <div class="clear foot">
                <button type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="rehab-btn-secondary">Send</button>
            </div>
        </div>
    </div>
</form>
</code>```

however if I input "aaa" as email address which is wrong. I am getting this error

Which obviosly breaks our UI,
by checking on the HTML in dev tools, it creates a new div with id "mce-inline-error"
out of the blue, how can i control this error so i can style it properly in our UI?

This is getting annoying google cant give me answer.

If there are no answers, what type of work around can you guys suggest?

Body:
this is my email form

<form action="https://gmail.us11.list-manage.com/subscribe/post?u=XXXXXX" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>

            <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">

<input type="text" name="b_fb16c0b54b243c41cf0ba431c_6cbe3da72c" tabindex="-1" value="">

                <button type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="rehab-btn-secondary">Send</button>

</form>

however if I input "aaa" as email address which is wrong. I am getting this error

Which obviosly breaks our UI,
by checking on the HTML in dev tools, it creates a new div with id "mce-inline-error"
out of the blue, how can i control this error so i can style it properly in our UI?

This is getting annoying google cant give me answer.

If there are no answers, what type of work around can you guys suggest?


问:
Python selenium cannot saved to default download path
Selenium 4.6.0
Python 3.10.9

If I'm using headless mode then this issue won't happen, files can be downloaded to Downloads/test folder.

But if it's non-headless mode it ignores the options prefs and download to Downloads folder.

```<code>options = webdriver.ChromeOptions()
ua = UserAgent()
userAgent = ua.random
print(userAgent)

options.add_argument('--user-agent=User-Agent: {}'.format(userAgent))
# options.add_argument('--headless')
options.add_argument("--user-data-dir=C:/Users/Myname/AppData/Local/Google/Chrome/User Data")
options.add_argument("--profile-directory=Profile 2")
prefs = {"download.default_directory" : r"C:\Users\Myname\Downloads\test\\"}
options.add_experimental_option("prefs", prefs)
self.webdriver = webdriver.Chrome(executable_path="../chromedriver_win32/chromedriver.exe",options=options)
self.webdriver.maximize_window()
print ("Headless Chrome Initialized")
</code>```

Body:
Selenium 4.6.0
Python 3.10.9

If I'm using headless mode then this issue won't happen, files can be downloaded to Downloads/test folder.

But if it's non-headless mode it ignores the options prefs and download to Downloads folder.

options = webdriver.ChromeOptions()
ua = UserAgent()
userAgent = ua.random
print(userAgent)

options.add_argument('--user-agent=User-Agent: {}'.format(userAgent))
# options.add_argument('--headless')
options.add_argument("--user-data-dir=C:/Users/Myname/AppData/Local/Google/Chrome/User Data")
options.add_argument("--profile-directory=Profile 2")
prefs = {"download.default_directory" : r"C:\Users\Myname\Downloads\test\\"}
options.add_experimental_option("prefs", prefs)
self.webdriver = webdriver.Chrome(executable_path="../chromedriver_win32/chromedriver.exe",options=options)
self.webdriver.maximize_window()
print ("Headless Chrome Initialized")


问:
google sign in sign in flow canceled iOS
I'm writing an iOS app that has to use google sign in. It compiles fine but when it runs and I try to sign in with a button, the sign in flow is interrupted:

```<code>This is the error: Optional("The operation couldn’t be completed. (com.google.GIDSignIn error -4.)")
error with signing in: Optional(Error Domain=com.google.GIDSignIn Code=-5 "The user canceled the sign-in flow." UserInfo={NSLocalizedDescription=The user canceled the sign-in flow.})
</code>```

In the simulator, when I press the button, it will show the dialog box asking whether it is ok for the app to access google and then it will just disappear after a second or two.

Here is my ViewController:

```<code>//
//  ViewController.swift
//  frcscout
//
//  Created by Elliot Scher on 12/20/22..
//

import UIKit
import GoogleSignIn
import GTMSessionFetcher
import GoogleAPIClientForREST

class ViewController: UIViewController {

    @IBOutlet weak var signInButton: UIButton!

    private let service = GTLRSheetsService()

    override func viewDidLoad() {
        super.viewDidLoad()

        googleSignIn { signInStatus in
            if signInStatus == true {
                self.signInButton?.setTitle("Sign out", for: .normal)
                print("Signed in!")
            } else {
                self.signInButton?.setTitle("Sign in", for: .normal)
                print("Issues with signing in...")
            }
        }
    }

    @IBAction func signInPressed(_ sender: UIButton) {

        print("Sign in pressed")

        let user = GIDSignIn.sharedInstance.currentUser
        if (user == nil) {
            googleSignIn() { success in
                if success == true {
                    sender.setTitle("Sign out", for: UIControl.State.normal)
                } else {
                    return
                }
            }
           } else {
               GIDSignIn.sharedInstance.signOut()
               self.service.authorizer = nil
               sender.setTitle("Sign in", for: UIControl.State.normal)
           }
        }
    }

extension ViewController {
    func googleSignIn(completionHandler: @escaping (Bool) -> Void) {
        GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
            if error == nil {
                print("Managed to restore previous sign in!\nScopes: \(String(describing: user?.grantedScopes))")

                self.requestScopes(googleUser: user!) { success in
                    if success == true {
                        completionHandler(true)
                    } else {
                        completionHandler(false)
                    }
                }
            } else {
                print("No previous user!\nThis is the error: \(String(describing: error?.localizedDescription))")
                let signInConfig = GIDConfiguration.init(clientID: K.clientID)
                GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { gUser, signInError in
                    if signInError == nil {
                        self.requestScopes(googleUser: gUser!) { signInSuccess in
                            if signInSuccess == true {
                                completionHandler(true)
                            } else {
                                completionHandler(false)
                            }
                        }
                    } else {
                        print("error with signing in: \(String(describing: signInError)) ")
                      self.service.authorizer = nil
                        completionHandler(false)
                    }
                }
            }
        }
    }

    func requestScopes(googleUser: GIDGoogleUser, completionHandler: @escaping (Bool) -> Void) {

        let grantedScopes = googleUser.grantedScopes
        if grantedScopes == nil || !grantedScopes!.contains(K.grantedScopes) {
            let additionalScopes = K.additionalScopes

            GIDSignIn.sharedInstance.addScopes(additionalScopes, presenting: self) { user, scopeError in
                if scopeError == nil {
                    user?.authentication.do { authentication, err in
                        if err == nil {
                            guard let authentication = authentication else { return }
                            // Get the access token to attach it to a REST or gRPC request.
                           // let accessToken = authentication.accessToken
                            let authorizer = authentication.fetcherAuthorizer()
                            self.service.authorizer = authorizer
                            completionHandler(true)
                        } else {
                            print("Error with auth: \(String(describing: err?.localizedDescription))")
                            completionHandler(false)
                        }
                    }
                } else {
                    completionHandler(false)
                    print("Error with adding scopes: \(String(describing: scopeError?.localizedDescription))")
                }
            }
        } else {
            print("Already contains the scopes!")
            completionHandler(true)
        }
    }
}
</code>```

Can anyone help me fix this? Thanks!!

Body:
I'm writing an iOS app that has to use google sign in. It compiles fine but when it runs and I try to sign in with a button, the sign in flow is interrupted:

This is the error: Optional("The operation couldn’t be completed. (com.google.GIDSignIn error -4.)")
error with signing in: Optional(Error Domain=com.google.GIDSignIn Code=-5 "The user canceled the sign-in flow." UserInfo={NSLocalizedDescription=The user canceled the sign-in flow.})

In the simulator, when I press the button, it will show the dialog box asking whether it is ok for the app to access google and then it will just disappear after a second or two.

Here is my ViewController:

//
//  ViewController.swift
//  frcscout
//
//  Created by Elliot Scher on 12/20/22..
//

import UIKit
import GoogleSignIn
import GTMSessionFetcher
import GoogleAPIClientForREST

class ViewController: UIViewController {

    @IBOutlet weak var signInButton: UIButton!

    private let service = GTLRSheetsService()

    override func viewDidLoad() {
        super.viewDidLoad()

        googleSignIn { signInStatus in
            if signInStatus == true {
                self.signInButton?.setTitle("Sign out", for: .normal)
                print("Signed in!")
            } else {
                self.signInButton?.setTitle("Sign in", for: .normal)
                print("Issues with signing in...")
            }
        }
    }

    @IBAction func signInPressed(_ sender: UIButton) {

        print("Sign in pressed")

        let user = GIDSignIn.sharedInstance.currentUser
        if (user == nil) {
            googleSignIn() { success in
                if success == true {
                    sender.setTitle("Sign out", for: UIControl.State.normal)
                } else {
                    return
                }
            }
           } else {
               GIDSignIn.sharedInstance.signOut()
               self.service.authorizer = nil
               sender.setTitle("Sign in", for: UIControl.State.normal)
           }
        }
    }

extension ViewController {
    func googleSignIn(completionHandler: @escaping (Bool) -> Void) {
        GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
            if error == nil {
                print("Managed to restore previous sign in!\nScopes: \(String(describing: user?.grantedScopes))")

                self.requestScopes(googleUser: user!) { success in
                    if success == true {
                        completionHandler(true)
                    } else {
                        completionHandler(false)
                    }
                }
            } else {
                print("No previous user!\nThis is the error: \(String(describing: error?.localizedDescription))")
                let signInConfig = GIDConfiguration.init(clientID: K.clientID)
                GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { gUser, signInError in
                    if signInError == nil {
                        self.requestScopes(googleUser: gUser!) { signInSuccess in
                            if signInSuccess == true {
                                completionHandler(true)
                            } else {
                                completionHandler(false)
                            }
                        }
                    } else {
                        print("error with signing in: \(String(describing: signInError)) ")
                      self.service.authorizer = nil
                        completionHandler(false)
                    }
                }
            }
        }
    }

    func requestScopes(googleUser: GIDGoogleUser, completionHandler: @escaping (Bool) -> Void) {

        let grantedScopes = googleUser.grantedScopes
        if grantedScopes == nil || !grantedScopes!.contains(K.grantedScopes) {
            let additionalScopes = K.additionalScopes

            GIDSignIn.sharedInstance.addScopes(additionalScopes, presenting: self) { user, scopeError in
                if scopeError == nil {
                    user?.authentication.do { authentication, err in
                        if err == nil {
                            guard let authentication = authentication else { return }
                            // Get the access token to attach it to a REST or gRPC request.
                           // let accessToken = authentication.accessToken
                            let authorizer = authentication.fetcherAuthorizer()
                            self.service.authorizer = authorizer
                            completionHandler(true)
                        } else {
                            print("Error with auth: \(String(describing: err?.localizedDescription))")
                            completionHandler(false)
                        }
                    }
                } else {
                    completionHandler(false)
                    print("Error with adding scopes: \(String(describing: scopeError?.localizedDescription))")
                }
            }
        } else {
            print("Already contains the scopes!")
            completionHandler(true)
        }
    }
}

Can anyone help me fix this? Thanks!!


问:
Is it possible to set up a default error page for Apigateway Aws Ingtegrations?
Goal

I have set up an apigateway rest api that has a s3 proxy using an aws integration.

Currently it is mostly working.

Problem

If I pass in a path that is not a key in the s3 bucket, I get an xml page that displays xml with a NoSuchKey error code.
For context, this s3 bucket is set up for static web hosting & it does have an index and error document specified.

Questions

Is it possible to return a default html page when aws integration response is a 404 error?

Do I need to change anything in the aws integration settings to get the s3 bucket to return it's error page instead of the nosuchkey xml?


问:
Node restart is prohibitively slow
So I use tsc-watch to watch my file and recompile typescript when changes are detected.

```<code>  "scripts": {
    "start": "node ./dist/index.js",
    "start:dev": "rimraf ./dist && mkdir ./dist && cp -R ./src/templates ./dist/templates && tsc-watch --noClear --onSuccess \"yarn start\"",
</code>```

This all works, and the incremental compliation from tsc-watch seems to be very fast,  however the node ./dist/index.js step takes 15-20 seconds. Which I believe is pretty slow, at least relative to other backend technologies I've used.

```<code>import { loadConfig } from "./config";
import createServer from "./server";

const start = async () => {
  const config = loadConfig();
  const server = await createServer(config);
  server.listen({
    port: config.mount.port,
    host: config.mount.hostname
  });
};

start();
</code>```

What could I do to improve this reload time?

Title: Node restart is prohibitively slow

Body:
So I use tsc-watch to watch my file and recompile typescript when changes are detected.

  "scripts": {
    "start": "node ./dist/index.js",
    "start:dev": "rimraf ./dist && mkdir ./dist && cp -R ./src/templates ./dist/templates && tsc-watch --noClear --onSuccess \"yarn start\"",

This all works, and the incremental compliation from tsc-watch seems to be very fast,  however the node ./dist/index.js step takes 15-20 seconds. Which I believe is pretty slow, at least relative to other backend technologies I've used.

import { loadConfig } from "./config";
import createServer from "./server";

const start = async () => {
  const config = loadConfig();
  const server = await createServer(config);
  server.listen({
    port: config.mount.port,
    host: config.mount.hostname
  });
};

start();

What could I do to improve this reload time?


问:
change the scale of the image and save it, it is saved horizontally unconditionally
In my code, if the image capacity is greater than 10 megabytes, resize the image.

And when I check the saved image, the image is always lying horizontally.

I've tried to solve this, but I don't know where the problem comes from.

How can I save the direction of the image as it is?

```<code>if (fileLength >= 1024 * 1024 && useImageResize == "Y")
{
    System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(file.InputStream);
    System.Drawing.Image objImage = WebMethods.ScaleImage(bmpPostedImage, 1080);

    using (var ms = new MemoryStream(1024 * 1024))
    {
        objImage.Save(ms, ImageFormat.Jpeg);
        fileLength = Methods.ConvInt32(ms.Length);
    }

    file.Save(newFilePath, ImageFormat.Jpeg);
}
</code>```
```<code>public static System.Drawing.Image ScaleImage(System.Drawing.Image image, int maxHeight)
{
    var ratio = (double)maxHeight / image.Height;
    var newWidth = (int)(image.Width * ratio);
    var newHeight = (int)(image.Height * ratio);
    var newImage = new Bitmap(newWidth, newHeight);
    using (var g = Graphics.FromImage(newImage))
    {
        g.DrawImage(image, 0, 0, newWidth, newHeight);
    }
    return newImage;
}
</code>```

Body:
In my code, if the image capacity is greater than 10 megabytes, resize the image.

And when I check the saved image, the image is always lying horizontally.

I've tried to solve this, but I don't know where the problem comes from.

How can I save the direction of the image as it is?

if (fileLength >= 1024 * 1024 && useImageResize == "Y")
{
    System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(file.InputStream);
    System.Drawing.Image objImage = WebMethods.ScaleImage(bmpPostedImage, 1080);

    using (var ms = new MemoryStream(1024 * 1024))
    {
        objImage.Save(ms, ImageFormat.Jpeg);
        fileLength = Methods.ConvInt32(ms.Length);
    }

    file.Save(newFilePath, ImageFormat.Jpeg);
}

public static System.Drawing.Image ScaleImage(System.Drawing.Image image, int maxHeight)
{
    var ratio = (double)maxHeight / image.Height;
    var newWidth = (int)(image.Width * ratio);
    var newHeight = (int)(image.Height * ratio);
    var newImage = new Bitmap(newWidth, newHeight);
    using (var g = Graphics.FromImage(newImage))
    {
        g.DrawImage(image, 0, 0, newWidth, newHeight);
    }
    return newImage;
}


问:
Does DPDK provide an interface to forward packets from one process to another?
Does DPDK provide an interface to forward packets from one process to another? Similar to the loopback mode of the kernel, but faster than the loopback mode.</p>


问:
Use `winget upgrade PACKAGE_NAME` within NodeJS `cp.spawn()`
When running the command winget upgrade PACKAGE_NAME within NodeJS cp.spawn(), the progress bar is going to stdout as parts of the process, not as a whole. How would I make it so I can detect every time progress has been made in downloading the file rather than after it's done downloading?

Current:

[
    'starting...',
    '\b \r\r  ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  17.0 MB / 79.4 MB\r  ████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒  43.0 MB / 79.4 MB\r  ████████████████████████▒▒▒▒▒▒  64.0 MB / 79.4 MB\r  ██████████████████████████▒▒▒▒  70.0 MB / 79.4 MB\r  █████████████████████████████▒  77.0 MB / 79.4 MB\r  ██████████████████████████████  79.4 MB / 79.4 MB\r\n',
    'done!',
]
```
<p><strong>What I want:</strong></p>
<pre class="lang-js prettyprint-override"><code>[
    'starting...',
    '\b \r\r  ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  17.0 MB / 79.4 MB',
    '\r  ████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒  43.0 MB / 79.4 MB',
    '\r  ████████████████████████▒▒▒▒▒▒  64.0 MB / 79.4 MB',
    '\r  ██████████████████████████▒▒▒▒  70.0 MB / 79.4 MB',
    '\r  █████████████████████████████▒  77.0 MB / 79.4 MB\r',
    '\r  ██████████████████████████████  79.4 MB / 79.4 MB\r\n',
    'done!',
]
</code>```

Body:
When running the command winget upgrade PACKAGE_NAME within NodeJS cp.spawn(), the progress bar is going to stdout as parts of the process, not as a whole. How would I make it so I can detect every time progress has been made in downloading the file rather than after it's done downloading?

Current:

[
    'starting...',
    '\b \r\r  ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  17.0 MB / 79.4 MB\r  ████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒  43.0 MB / 79.4 MB\r  ████████████████████████▒▒▒▒▒▒  64.0 MB / 79.4 MB\r  ██████████████████████████▒▒▒▒  70.0 MB / 79.4 MB\r  █████████████████████████████▒  77.0 MB / 79.4 MB\r  ██████████████████████████████  79.4 MB / 79.4 MB\r\n',
    'done!',
]

What I want:

[
    'starting...',
    '\b \r\r  ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  17.0 MB / 79.4 MB',
    '\r  ████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒  43.0 MB / 79.4 MB',
    '\r  ████████████████████████▒▒▒▒▒▒  64.0 MB / 79.4 MB',
    '\r  ██████████████████████████▒▒▒▒  70.0 MB / 79.4 MB',
    '\r  █████████████████████████████▒  77.0 MB / 79.4 MB\r',
    '\r  ██████████████████████████████  79.4 MB / 79.4 MB\r\n',
    'done!',
]


问:
Hibernate accusing non existence of a table that exists
I was just doing some practice coding with SprinBoot and Hibernate and I bumped into a problem I still can't figure out why it happens.

MYSQL: 8

Hibernate: 6

I have the Classroom class:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "SALA_DE_AULA")
public class Classroom {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "numero_sala")
    private Integer roomNumber;

    @Column(name = "capacidade_alunos")
    private Integer studentCapacity;

    @Column(name = "alunos")
    @OneToMany(mappedBy = "classroom")
    private List<Student> students;
}
```
<p>And the <strong>Student</strong> class:</p>
<pre class="lang-java prettyprint-override"><code>@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "ESTUDANTE")
public class Student {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

    @Column(name = "primeiro_nome", length = 72)
    private String firstName;

    @Column(name = "sobrenome", length = 72)
    private String lastName;

    @Column(name = "cpf", unique = true, nullable = false)
    private String cpf;

    @ManyToOne
    @JoinColumn(name = "sala_id")
    private Classroom classroom;

}
</code>```

I ommited the imports and package declaration for simplicity and brevity.

Then, I have the application.yml:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect
```
<p>So, I have tried these scenarios (did not change the classes, only the application.yml):</p>
<p><strong>SCENARIO 1</strong></p>
```spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect
```
<p>Properties <code>generate-ddl: true</code> and <code>hibernate.ddl-auto: create</code> as well as <code>update</code> and <code>create-drop</code>, etc. The result was:</p>
<p><strong>RESULT 1</strong></p>
```  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m              [2m (v3.0.0)[0;39m

[2m2022-12-20T22:27:34.715-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mbr.com.chromatec.Application            [0;39m [2m:[0;39m Starting Application using Java 17.0.4.1 with PID 21332 (D:\Studies\Entrevistas\exercicios\crud-school-spring\target\classes started by Usuario in D:\Studies\Entrevistas\exercicios\crud-school-spring)
[2m2022-12-20T22:27:34.721-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mbr.com.chromatec.Application            [0;39m [2m:[0;39m No active profile set, falling back to 1 default profile: "default"
[2m2022-12-20T22:27:35.845-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[2m2022-12-20T22:27:35.904-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 30 ms. Found 0 JPA repository interfaces.
[2m2022-12-20T22:27:37.221-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2022-12-20T22:27:37.268-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2022-12-20T22:27:37.269-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardEngine   [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/10.1.1]
[2m2022-12-20T22:27:37.528-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2022-12-20T22:27:37.528-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 2741 ms
[2m2022-12-20T22:27:37.812-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2022-12-20T22:27:37.927-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate ORM core version 6.1.5.Final
[2m2022-12-20T22:27:38.414-03:00[0;39m [33m WARN[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.orm.deprecation           [0;39m [2m:[0;39m HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
[2m2022-12-20T22:27:38.563-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2022-12-20T22:27:39.074-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.zaxxer.hikari.pool.HikariPool       [0;39m [2m:[0;39m HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@473847fb
[2m2022-12-20T22:27:39.084-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2022-12-20T22:27:39.208-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mSQL dialect                             [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Hibernate: alter table estudante drop foreign key FKqciufquggwt9hpd6pcwsvhjwp
[2m2022-12-20T22:27:40.625-03:00[0;39m [33m WARN[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.h.t.s.i.ExceptionHandlerLoggedImpl    [0;39m [2m:[0;39m GenerationTarget encountered exception accepting command : Error executing DDL "alter table estudante drop foreign key FKqciufquggwt9hpd6pcwsvhjwp" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table estudante drop foreign key FKqciufquggwt9hpd6pcwsvhjwp" via JDBC Statement
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:419) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:403) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applyConstraintDropping(SchemaDropperImpl.java:373) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:256) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:178) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:149) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:117) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:242) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.lambda$process$5(SchemaManagementToolCoordinator.java:143) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at java.base/java.util.HashMap.forEach(HashMap.java:1421) ~[na:na]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:140) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:334) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1425) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:66) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1130) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:905) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0.jar:3.0.0]
    at br.com.chromatec.Application.main(Application.java:10) ~[classes/:na]
Caused by: java.sql.SQLSyntaxErrorException: Table 'crud_school_spring_db.estudante' doesn't exist
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:763) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-5.0.1.jar:na]
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-5.0.1.jar:na]
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    ... 37 common frames omitted

Hibernate: drop table if exists estudante
Hibernate: drop table if exists sala_de_aula
Hibernate: drop table if exists sala_de_aula_seq
Hibernate: create table estudante (id binary(16) not null, cpf varchar(255) not null, primeiro_nome varchar(72), sobrenome varchar(72), sala_id bigint, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula (id bigint not null, numero_sala integer, capacidade_alunos integer, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula_seq (next_val bigint) engine=InnoDB
Hibernate: insert into sala_de_aula_seq values ( 1 )
Hibernate: alter table estudante add constraint UK_5nxev4xg82u16sq0ihppdvurf unique (cpf)
Hibernate: alter table estudante add constraint FKqciufquggwt9hpd6pcwsvhjwp foreign key (sala_id) references sala_de_aula (id)
[2m2022-12-20T22:27:40.839-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.h.e.t.j.p.i.JtaPlatformInitiator      [0;39m [2m:[0;39m HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[2m2022-12-20T22:27:40.873-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2022-12-20T22:27:40.953-03:00[0;39m [33m WARN[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mJpaBaseConfiguration$JpaWebConfiguration[0;39m [2m:[0;39m spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
[2m2022-12-20T22:27:41.702-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port(s): 8080 (http) with context path ''
[2m2022-12-20T22:27:41.736-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mbr.com.chromatec.Application            [0;39m [2m:[0;39m Started Application in 8.032 seconds (process running for 9.685)

```
<p>But when I check the Workbench, the tables are there.
That leads to the next scenario:</p>
<p><strong>SCENARIO 2</strong></p>
```spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    #generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect
```
<p>I thought that both commands were conflicting, so I commented out the <code>generate-ddl</code> line.</p>
<p><strong>RESULT 2</strong></p>
<p>Exactly the same output and SQL commands. And the tables were generated as well.</p>
<p><strong>SCENARIO 3</strong></p>
```spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    generate-ddl: true
    show-sql: true
    #hibernate:
    #  ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect
```
<p>I commented out the hibernate specific lines.</p>
<p><strong>RESULT 3</strong></p>
<p>No error was thrown. And the SQL output was slightly different:</p>
```Hibernate: create table estudante (id binary(16) not null, cpf varchar(255) not null, primeiro_nome varchar(72), sobrenome varchar(72), sala_id bigint, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula (id bigint not null, numero_sala integer, capacidade_alunos integer, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula_seq (next_val bigint) engine=InnoDB
Hibernate: insert into sala_de_aula_seq values ( 1 )
Hibernate: alter table estudante drop index UK_5nxev4xg82u16sq0ihppdvurf
Hibernate: alter table estudante add constraint UK_5nxev4xg82u16sq0ihppdvurf unique (cpf)
Hibernate: alter table estudante add constraint FKqciufquggwt9hpd6pcwsvhjwp foreign key (sala_id) references sala_de_aula (id)
```

With an extra command alter table estudante drop index UK_5nxev4xg82u16sq0ihppdvurf.

MY CONCLUSION(?)

I haven't yet tested if the persistence flow is working correctly, but I don't think it's relevant to this problem. Is my hibernate configuration wrong?

Body:
I was just doing some practice coding with SprinBoot and Hibernate and I bumped into a problem I still can't figure out why it happens.

MYSQL: 8

Hibernate: 6

I have the Classroom class:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "SALA_DE_AULA")
public class Classroom {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "numero_sala")
    private Integer roomNumber;

    @Column(name = "capacidade_alunos")
    private Integer studentCapacity;

    @Column(name = "alunos")
    @OneToMany(mappedBy = "classroom")
    private List<Student> students;
}

And the Student class:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "ESTUDANTE")
public class Student {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

    @Column(name = "primeiro_nome", length = 72)
    private String firstName;

    @Column(name = "sobrenome", length = 72)
    private String lastName;

    @Column(name = "cpf", unique = true, nullable = false)
    private String cpf;

    @ManyToOne
    @JoinColumn(name = "sala_id")
    private Classroom classroom;

}

I ommited the imports and package declaration for simplicity and brevity.

Then, I have the application.yml:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect

So, I have tried these scenarios (did not change the classes, only the application.yml):

SCENARIO 1

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect

Properties generate-ddl: true and hibernate.ddl-auto: create as well as update and create-drop, etc. The result was:

RESULT 1

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m              [2m (v3.0.0)[0;39m

[2m2022-12-20T22:27:34.715-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mbr.com.chromatec.Application            [0;39m [2m:[0;39m Starting Application using Java 17.0.4.1 with PID 21332 (D:\Studies\Entrevistas\exercicios\crud-school-spring\target\classes started by Usuario in D:\Studies\Entrevistas\exercicios\crud-school-spring)
[2m2022-12-20T22:27:34.721-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mbr.com.chromatec.Application            [0;39m [2m:[0;39m No active profile set, falling back to 1 default profile: "default"
[2m2022-12-20T22:27:35.845-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[2m2022-12-20T22:27:35.904-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 30 ms. Found 0 JPA repository interfaces.
[2m2022-12-20T22:27:37.221-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2022-12-20T22:27:37.268-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2022-12-20T22:27:37.269-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardEngine   [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/10.1.1]
[2m2022-12-20T22:27:37.528-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2022-12-20T22:27:37.528-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 2741 ms
[2m2022-12-20T22:27:37.812-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2022-12-20T22:27:37.927-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate ORM core version 6.1.5.Final
[2m2022-12-20T22:27:38.414-03:00[0;39m [33m WARN[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.orm.deprecation           [0;39m [2m:[0;39m HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
[2m2022-12-20T22:27:38.563-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2022-12-20T22:27:39.074-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.zaxxer.hikari.pool.HikariPool       [0;39m [2m:[0;39m HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@473847fb
[2m2022-12-20T22:27:39.084-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2022-12-20T22:27:39.208-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mSQL dialect                             [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Hibernate: alter table estudante drop foreign key FKqciufquggwt9hpd6pcwsvhjwp
[2m2022-12-20T22:27:40.625-03:00[0;39m [33m WARN[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.h.t.s.i.ExceptionHandlerLoggedImpl    [0;39m [2m:[0;39m GenerationTarget encountered exception accepting command : Error executing DDL "alter table estudante drop foreign key FKqciufquggwt9hpd6pcwsvhjwp" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table estudante drop foreign key FKqciufquggwt9hpd6pcwsvhjwp" via JDBC Statement
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:419) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:403) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applyConstraintDropping(SchemaDropperImpl.java:373) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:256) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:178) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:149) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:117) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:242) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.lambda$process$5(SchemaManagementToolCoordinator.java:143) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at java.base/java.util.HashMap.forEach(HashMap.java:1421) ~[na:na]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:140) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:334) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1425) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:66) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1130) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:905) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0.jar:3.0.0]
    at br.com.chromatec.Application.main(Application.java:10) ~[classes/:na]
Caused by: java.sql.SQLSyntaxErrorException: Table 'crud_school_spring_db.estudante' doesn't exist
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:763) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648) ~[mysql-connector-j-8.0.31.jar:8.0.31]
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-5.0.1.jar:na]
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-5.0.1.jar:na]
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    ... 37 common frames omitted

Hibernate: drop table if exists estudante
Hibernate: drop table if exists sala_de_aula
Hibernate: drop table if exists sala_de_aula_seq
Hibernate: create table estudante (id binary(16) not null, cpf varchar(255) not null, primeiro_nome varchar(72), sobrenome varchar(72), sala_id bigint, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula (id bigint not null, numero_sala integer, capacidade_alunos integer, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula_seq (next_val bigint) engine=InnoDB
Hibernate: insert into sala_de_aula_seq values ( 1 )
Hibernate: alter table estudante add constraint UK_5nxev4xg82u16sq0ihppdvurf unique (cpf)
Hibernate: alter table estudante add constraint FKqciufquggwt9hpd6pcwsvhjwp foreign key (sala_id) references sala_de_aula (id)
[2m2022-12-20T22:27:40.839-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.h.e.t.j.p.i.JtaPlatformInitiator      [0;39m [2m:[0;39m HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[2m2022-12-20T22:27:40.873-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2022-12-20T22:27:40.953-03:00[0;39m [33m WARN[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mJpaBaseConfiguration$JpaWebConfiguration[0;39m [2m:[0;39m spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
[2m2022-12-20T22:27:41.702-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port(s): 8080 (http) with context path ''
[2m2022-12-20T22:27:41.736-03:00[0;39m [32m INFO[0;39m [35m21332[0;39m [2m---[0;39m [2m[           main][0;39m [36mbr.com.chromatec.Application            [0;39m [2m:[0;39m Started Application in 8.032 seconds (process running for 9.685)

But when I check the Workbench, the tables are there.
That leads to the next scenario:

SCENARIO 2

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    #generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect

I thought that both commands were conflicting, so I commented out the generate-ddl line.

RESULT 2

Exactly the same output and SQL commands. And the tables were generated as well.

SCENARIO 3

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/crud_school_spring_db
    username: my_root
    password: my_root_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    generate-ddl: true
    show-sql: true
    #hibernate:
    #  ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect

I commented out the hibernate specific lines.

RESULT 3

No error was thrown. And the SQL output was slightly different:

Hibernate: create table estudante (id binary(16) not null, cpf varchar(255) not null, primeiro_nome varchar(72), sobrenome varchar(72), sala_id bigint, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula (id bigint not null, numero_sala integer, capacidade_alunos integer, primary key (id)) engine=InnoDB
Hibernate: create table sala_de_aula_seq (next_val bigint) engine=InnoDB
Hibernate: insert into sala_de_aula_seq values ( 1 )
Hibernate: alter table estudante drop index UK_5nxev4xg82u16sq0ihppdvurf
Hibernate: alter table estudante add constraint UK_5nxev4xg82u16sq0ihppdvurf unique (cpf)
Hibernate: alter table estudante add constraint FKqciufquggwt9hpd6pcwsvhjwp foreign key (sala_id) references sala_de_aula (id)

With an extra command alter table estudante drop index UK_5nxev4xg82u16sq0ihppdvurf.

MY CONCLUSION(?)

I haven't yet tested if the persistence flow is working correctly, but I don't think it's relevant to this problem. Is my hibernate configuration wrong?


问:
Migrating the database from Oracle to MySQL What Changes has to be done in hibernate
Currently in our spring boot application bwe are using ojdbc jar and hibernate jars.We are planning to migrate to MySQL.
Are MySQL jars compatible with hibernate jars, also are there any drastic changes that one will have to do the dao layer when the migration is done(eg:the id generation strategies, @embedded,composite keys)

In application.properties we will have to change the connection strings.
But what else has to be taken care of


问:
Converting nvarchar(255) in SQL Server to varchar in MariaDB?
I am using CData Sync to convert my table in SQL Server to MariaDB. The data type I have for some of my columns (including my primary key) is nvarchar(255) and when I try to convert it using CData sync to a MariaDB table, it throws an error stating: #1170 error (42000) blob/Text Column Used in key specification without a key length. In the table mapping section in CData I see the column data types are being mapped correctly (nvarchar to varchar) but I think because the length on the source table is nvarchar(255) it's converting to varchar(510)? Which is too big so it's reading varchar as a TEXT/BLOB instead? None of my columns are specified as TEXT/BLOB so I'm not sure where CData Sync is getting that from. How do I convert nvarchar(255) to varchar? Would it be varchar(255) or varchar(512)?


问:
Fail at running sail:publish command in Sail Laravel 9
I'm trying to create a dockerfile file to run xdebug
but when I'm trying to run sail artisan sail:publish I've got this

```<code>   INFO  Publishing [sail-docker] assets.

   League\Flysystem\UnableToCreateDirectory

  Unable to create a directory at /var/www/html/docker/.

  at vendor/league/flysystem/src/UnableToCreateDirectory.php:20
     16▕
     17▕     public static function atLocation(string $dirname, string $errorMessage = '', ?Throwable $previous = null): UnableToCreateDirectory
     18▕     {
     19▕         $message = "Unable to create a directory at {$dirname}. {$errorMessage}";
  ➜  20▕         $e = new static(rtrim($message), 0, $previous);
     21▕         $e->location = $dirname;
     22▕
     23▕         return $e;
     24▕     }

      +31 vendor frames
  32  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

</code>```

image

I've tried this so far
sudo chown -R $USER:$USER ./vendor/
sudo chmod -R 755 /var/www/storage
sudo chmod 777 docker-compose.yml -Rf

Body:
I'm trying to create a dockerfile file to run xdebug
but when I'm trying to run sail artisan sail:publish I've got this

   INFO  Publishing [sail-docker] assets.

   League\Flysystem\UnableToCreateDirectory

  Unable to create a directory at /var/www/html/docker/.

  at vendor/league/flysystem/src/UnableToCreateDirectory.php:20
     16▕
     17▕     public static function atLocation(string $dirname, string $errorMessage = '', ?Throwable $previous = null): UnableToCreateDirectory
     18▕     {
     19▕         $message = "Unable to create a directory at {$dirname}. {$errorMessage}";
  ➜  20▕         $e = new static(rtrim($message), 0, $previous);
     21▕         $e->location = $dirname;
     22▕
     23▕         return $e;
     24▕     }

      +31 vendor frames
  32  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

image

I've tried this so far
sudo chown -R $USER:$USER ./vendor/
sudo chmod -R 755 /var/www/storage
sudo chmod 777 docker-compose.yml -Rf


问:
The results from using the Skender Stock Indicator Library are returning as memory addresses rather than values, how do I get the values?
I'm using the Stock Indicators module in Python. I've looked at the documentation to determine how to make a Quote, and then use that in the different functions to determine an indicator. It looks a bit like this:

```<code>import pandas as pd
from stock_indicators import CandlePart, indicators, Quote
from datetime import datetime

df = pd.read_csv("my/file/path/file.csv")

for i in range(len(df.iloc[:,0])):
    df.iloc[i,0] = datetime.strptime(df.iloc[i,0], "%Y-%m-%d")

quotes_list = [
    Quote(d,o,h,l,c,v)
    for d,o,h,l,c,v
    in zip(df['Date'], df['Open'], df['High'], df['Low'], df['Close'], df['Volume'])
]

results = indicators.get_sma(quotes_list, 20, CandlePart.VOLUME)
</code>```

But then, when I use the method .find on results, or

```<code>print(results.find(df.iloc[21,0]))
</code>```

it returns with

```<code><stock_indicators.indicators.sma.SMAResult object at 0x000001837FEB3820>
</code>```

Now, I've spent quite a bit of time looking at the code, and understand that there is some C# code that is used, and there are conversions between Python objects and C# objects, but that isn't anything I should need to worry about, not that I'm aware of.

In addition, I read that when using the zip function, it will return the memory address at times, rather than the actual value. So, I constructed the quote_list differently than what is above, where I iterated over the dataframe differently with a for loop, creating a quote one at a time without using the zip function, but it still had the same results.

So how can I access the results values, rather than the object type and memory address? Is it due to the way that my quotes_list is constructed, or does it have to do with how I am trying to access the info from results?

Body:
I'm using the Stock Indicators module in Python. I've looked at the documentation to determine how to make a Quote, and then use that in the different functions to determine an indicator. It looks a bit like this:

import pandas as pd
from stock_indicators import CandlePart, indicators, Quote
from datetime import datetime

df = pd.read_csv("my/file/path/file.csv")

for i in range(len(df.iloc[:,0])):
    df.iloc[i,0] = datetime.strptime(df.iloc[i,0], "%Y-%m-%d")

quotes_list = [
    Quote(d,o,h,l,c,v)
    for d,o,h,l,c,v
    in zip(df['Date'], df['Open'], df['High'], df['Low'], df['Close'], df['Volume'])
]

results = indicators.get_sma(quotes_list, 20, CandlePart.VOLUME)

But then, when I use the method .find on results, or

print(results.find(df.iloc[21,0]))

it returns with

<stock_indicators.indicators.sma.SMAResult object at 0x000001837FEB3820>

Now, I've spent quite a bit of time looking at the code, and understand that there is some C# code that is used, and there are conversions between Python objects and C# objects, but that isn't anything I should need to worry about, not that I'm aware of.

In addition, I read that when using the zip function, it will return the memory address at times, rather than the actual value. So, I constructed the quote_list differently than what is above, where I iterated over the dataframe differently with a for loop, creating a quote one at a time without using the zip function, but it still had the same results.

So how can I access the results values, rather than the object type and memory address? Is it due to the way that my quotes_list is constructed, or does it have to do with how I am trying to access the info from results?